Java8 provides Next-Generation JavaScript Engine as nashorn. We can get this engine with following code:
ScriptEngineManager engineManager = new ScriptEngineManager();
ScriptEngine engine = engineManager.getEngineByName("nashorn");
But i found that javascript and ECMAScript are also valid parameters for getEngineByName()
ScriptEngine engine = engineManager.getEngineByName("javascript");
ScriptEngine engine = engineManager.getEngineByName("ECMAScript");
My queries are:
Javascript and ECMAScript are aliases for default JavaScript engine bundled with JVM. Java 8+ includes Nashorn engine, previous versions were using Rhino engine ("rhino"). Nashorn is much faster than Rhino, because it is compiling JavaScript into bytecode, instead of running in interpreter mode.
The fastest solution I know of to run JavaScript within JVM is J2V8 (https://github.com/eclipsesource/J2V8). JavaScript code runs within the V8 engine, the same one as is used by Node.js and Chrome. In our tests, it's about 2-3 times faster than Nashorn.
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