JavaScript Engine Changed in Java SE 8

Q

What is the default JavaScript Engine in Java SE 8?

✍: FYIcenter

A

The default JavaScript engine has been changed in Java SE 8:

  • Java SE 8 - jdk.nashorn.api.scripting.NashornScriptEngine
  • Java SE 7 - com.sun.script.javascript.RhinoScriptEngine

You can run the sample Java program, JavaScriptEngineInfo.java, in Java SE 7 first:

>\fyicenter\jdk-1.7.0\bin\javac JavaScriptEngineInfo.java

>\fyicenter\jdk-1.7.0\bin\java JavaScriptEngineInfo

From JavaScript:
   Hello world!

JavaScript engine info:
   Engine name: Mozilla Rhino
   Engine version: 1.7 release 3 PRERELEASE
   Language name: ECMAScript
   Language version: 1.8
   Engine class: com.sun.script.javascript.RhinoScriptEngine
   Factory class: com.sun.script.javascript.RhinoScriptEngineFactory
   Manager class: javax.script.ScriptEngineManager

Then run it again in Java SE 8:

>\fyicenter\jdk-1.8.0\bin\java JavaScriptEngineInfo

From JavaScript:
   Hello world!

JavaScript engine info:
   Engine name: Oracle Nashorn
   Engine version: 1.8.0_131
   Language name: ECMAScript
   Language version: ECMA - 262 Edition 5.1
   Engine class: jdk.nashorn.api.scripting.NashornScriptEngine
   Factory class: jdk.nashorn.api.scripting.NashornScriptEngineFactory
   Manager class: javax.script.ScriptEngineManager

The the JavaScript engine is different in Java SE 8 from 7.

 

SJP (Scripting for the Java Platform) API

⇒⇒FAQ for Rhino JavaScript Java Library

2017-07-25, 664👍, 0💬