Cant get Nashorn engine
ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
engine.eval("print('Hello World!');");
engine
returns null
I am using eclipse, jdk1.8.0_11
java -version
java version "1.8.0_20-ea"
Java(TM) SE Runtime Environment (build 1.8.0_20-ea-b23)
Its working when I pass null param into ScriptEngineManager constructor:
ScriptEngine engine = new ScriptEngineManager(null).getEngineByName("nashorn");
engine.eval("print('Hello World!');");
from java docs
ScriptEngineManager(ClassLoader loader)
If loader is null, the script engine factories that are bundled with the platform and that are in the usual extension directories (installed extensions) are loaded.
Old question but in case you didn't have any joy... you might try this instead...
ScriptEngine engine = new NashornScriptEngineFactory().getScriptEngine();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With