$ jjs - DmyKey = myValue
jjs > java . lang . System . getProperty ( "myKey" );
• -v or -version is the standard Nashorn version string.
• -fv or -fullversion prints the full Nashorn version string.
• -fx is used to execute a script as a JavaFX GUI application. This allows a Jav‐
aFX programmer to write a lot less boilerplate by making use of Nashorn. 1
• -h is the standard help switch.
• -scripting can be used to enable Nashorn-specific scripting extensions. This
is the subject of the next subsection.
Scripting with jjs
slightly hampered by lacking multiline input and other more advanced features that
are often expected when developing with languages that make heavy use of a REPL.
Instead, jjs is very suitable for noninteractive use, such as bringing up a daemon
$ jjs - scripting my_script . js
This enables us to make use of the enhanced features of jjs . These include some
useful extensions, many of which make using Nashorn slightly more familiar to the
In traditional Unix scripting, the # character is used to indicate a comment that runs
include // to indicate a comment that runs to the end of the line. Nashorn conforms
to this as well, but in scripting mode also accepts the Unix scripting style, so that
this code is perfectly legal:
# !/ usr / bin / jjs
# A perfectly legal comment in scripting mode
print ( "After the comment" );
1 JavaFX is a standard Java technology used for making GUIs—but it is outside the scope of this