Created
February 12, 2015 00:22
-
-
Save dragon0/8b262638bae3b2d0951b to your computer and use it in GitHub Desktop.
Print Available Java Script Engines
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.script.*; | |
public class ScriptEngineQuery{ | |
public static void main(String[] args){ | |
ScriptEngineManager manager = new ScriptEngineManager(); | |
for(ScriptEngineFactory factory : manager.getEngineFactories()){ | |
System.out.println("Engine: " + factory.getEngineName()); | |
System.out.println( | |
"Language: " | |
+ factory.getLanguageName() | |
+ " (" + factory.getLanguageVersion() + ")" ); | |
System.out.println("Alternate Language Names:"); | |
for(String name : factory.getNames()){ | |
System.out.println("\t" + name); | |
//manager.getEngineByName(name); | |
} | |
System.out.println("Recoginzed MIME Types:"); | |
for(String type : factory.getMimeTypes()){ | |
System.out.println("\t" + type); | |
//manager.getEngineByMimeType(type); | |
} | |
System.out.println("Recognized Filename Extensions:"); | |
for(String ext : factory.getExtensions()){ | |
System.out.println("\t" + ext); | |
//manager.getEngineByExtension(ext); | |
} | |
ScriptEngine engine = factory.getScriptEngine(); | |
if (engine instanceof Compilable){ | |
System.out.println( | |
"Engine can compile scripts for greater efficiency"); | |
//Compilable cEngine = (Compilable) engine; | |
} | |
if (engine instanceof Invocable){ | |
System.out.println( | |
"Engine allows Java to call functions defined in this language"); | |
//Invocable iEngine = (Invocable) engine; | |
} | |
System.out.println(); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment