jjs - command-line tool to invoke the Nashorn engine
Note: The jjs tool and the Nashorn engine are deprecated in JDK 11 in preparation for removal in a future release.
jjs [options] script-files [-- arguments]
jjs command, separated by spaces. See Options for the jjs Command.
--) are passed through to the script or the interactive shell as arguments. These values can be accessed by using the arguments property.
The jjs command-line tool is used to invoke the Nashorn engine. You can use it to interpret one or several script files, or to run an interactive shell.
The options of the jjs command control the conditions under which scripts are interpreted by Nashorn engine.
-Dname=valueSets a system property to be passed to the script by assigning a value to a property name. The following example shows how to invoke Nashorn engine in interactive mode and assign myValue to the property named myKey:
>> jjs -DmyKey=myValue
jjs> java.lang.System.getProperty("myKey")
myValue
jjs>
This option can be repeated to set multiple properties.
--add-modules modules-cp path or -classpath pathSpecifies the path to the supporting class files. To set multiple paths, the option can be repeated, or you can separate each path with the following character:
Oracle Solaris, Linux, and OS X: Colon (:)
Windows: Semicolon (;)
-doe=[true|false] or -dump-on-error=[true|false]false.
-fv=[true|false] or -fullversion=[true|false]false.
-fx=[true|false]Launches the script as a JavaFX application. The default parameter is false.
Note:
You must explicitly add the JavaFX modules to launch the script as a JavaFX application. The following example specifies the location of the JavaFX modules and adds them with the --module-path and --add-modules options:
jjs -fx --module-path /SOMEDIR/javafx-sdk-11/lib --add-modules javafx.controls HelloWorld.js
The following example uses the jlink command to create a custom runtime image that contains the JavaFX modules. The example then launches a script as a JavaFX application without specifying the JavaFX modules in the jjs command:
jlink --module-path /SOMEDIR/javafx-jmods-11 --add-modules jdk.scripting.nashorn,jdk.scripting.nashorn.shell,javafx.controls --output /SOMEDIR/myjdk
/SOMEDIR/myjdk/bin/jjs -fx HelloWorld.js
If you don't explicitly specify the JavaFX modules, then the jjs command prints a message and exits:
jjs -fx HelloWorld.js
JavaFX is not available.
-h or -help--language=[es5|es6]--module-path path-ot=[true|false] or -optimistic-types=[true|false]true.
-scripting=[true|false]true.
-strict=[true|false]false.
-t=zone or -timezone=zoneDate object. The default zone is America/Los_Angeles.
-v=[true|false] or-version=[true|false]false.
jjs script.js
>> jjs
jjs> println("Hello, World!")
Hello, World!
jjs> quit()
>>
>> jjs -- a b c
jjs> arguments.join(", ")
a, b, c
jjs>