这里有一个小片段列出所有支持的引擎
public class Script {
public static void main(String[] args) throws ScriptException {
new ScriptEngineManager().getEngineByName("js")
.eval("print('Hello from Java\\n');");
for (ScriptEngineFactory se : new ScriptEngineManager().getEngineFactories()) {
System.out.println("se = " + se.getEngineName());
System.out.println("se = " + se.getEngineVersion());
System.out.println("se = " + se.getLanguageName());
System.out.println("se = " + se.getLanguageVersion());
System.out.println("se = " + se.getNames());
}
}
}
Java 6 (1.6.0_43)
Hello from Java
se = Mozilla Rhino
se = 1.6 release 2
se = ECMAScript
se = 1.6
se = [js, rhino, JavaScript, javascript, ECMAScript, ecmascript]
Java 7 (1.7.0_40)
Hello from Java
se = Mozilla Rhino
se = 1.7 release 3 PRERELEASE
se = ECMAScript
se = 1.8
se = [js, rhino, JavaScript, javascript, ECMAScript, ecmascript]
Java 8 (1.8.0_74)
Hello from Java
se = Oracle Nashorn
se = 1.8.0_74
se = ECMAScript
se = ECMA - 262 Edition 5.1
se = [nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript]