.\" Copyright (c) 1994, 2019, Oracle and/or its affiliates. All rights reserved. .\" DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. .\" .\" This code is free software; you can redistribute it and/or modify it .\" under the terms of the GNU General Public License version 2 only, as .\" published by the Free Software Foundation. .\" .\" This code is distributed in the hope that it will be useful, but WITHOUT .\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or .\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License .\" version 2 for more details (a copy is included in the LICENSE file that .\" accompanied this code). .\" .\" You should have received a copy of the GNU General Public License version .\" 2 along with this work; if not, write to the Free Software Foundation, .\" Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. .\" .\" Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA .\" or visit www.oracle.com if you need additional information or have any .\" questions. .\" .\" Automatically generated by Pandoc 2.3.1 .\" .TH "JJS" "1" "2020" "JDK 14" "JDK Commands" .hy .SH NAME .PP jjs \- command\-line tool to invoke the Nashorn engine .SH SYNOPSIS .PP \f[B]Note:\f[R] The \f[CB]jjs\f[R] tool and the Nashorn engine are deprecated in JDK 11 in preparation for removal in a future release. .PP \f[CB]jjs\f[R] [\f[I]options\f[R]] \f[I]script\-files\f[R] [\f[CB]\-\-\f[R] \f[I]arguments\f[R]] .TP .B \f[I]options\f[R] This represents one or more options of the \f[CB]jjs\f[R] command, separated by spaces. See \f[B]Options for the jjs Command\f[R]. .RS .RE .TP .B \f[I]script\-files\f[R] This represents one or more script files that you want to interpret using the Nashorn engine, separated by spaces. If no files are specified, then an interactive shell is started. .RS .RE .TP .B \f[I]arguments\f[R] All values after the double hyphen marker (\f[CB]\-\-\f[R]) are passed through to the script or the interactive shell as arguments. These values can be accessed by using the \f[CB]arguments\f[R] property. .RS .RE .SH DESCRIPTION .PP The \f[CB]jjs\f[R] 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. .SH OPTIONS FOR THE JJS COMMAND .PP The options of the \f[CB]jjs\f[R] command control the conditions under which scripts are interpreted by Nashorn engine. .TP .B \f[CB]\-D\f[R]\f[I]name\f[R]\f[CB]=\f[R]\f[I]value\f[R] Sets 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 \f[CB]myValue\f[R] to the property named \f[CB]myKey\f[R]: .RS .IP .nf \f[CB] >>\ jjs\ \-DmyKey=myValue jjs>\ java.lang.System.getProperty("myKey") myValue jjs> \f[R] .fi .PP This option can be repeated to set multiple properties. .RE .TP .B \f[CB]\-\-add\-modules\f[R] \f[I]modules\f[R] Specifies the root user Java modules. .RS .RE .TP .B \f[CB]\-cp\f[R] \f[I]path\f[R] or \f[CB]\-classpath\f[R] \f[I]path\f[R] Specifies 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: .RS .IP \[bu] 2 \f[B]Oracle Solaris, Linux, and OS X:\f[R] Colon (\f[CB]:\f[R]) .IP \[bu] 2 \f[B]Windows:\f[R] Semicolon (\f[CB];\f[R]) .RE .TP .B \f[CB]\-doe=\f[R][\f[CB]true\f[R]|\f[CB]false\f[R]] or \f[CB]\-dump\-on\-error=\f[R][\f[CB]true\f[R]|\f[CB]false\f[R]] Provides a full stack trace when an error occurs. By default, only a brief error message is printed. The default parameter is \f[CB]false\f[R]. .RS .RE .TP .B \f[CB]\-fv=\f[R][\f[CB]true\f[R]|\f[CB]false\f[R]] or \f[CB]\-fullversion=\f[R][\f[CB]true\f[R]|\f[CB]false\f[R]] Prints the full Nashorn version string. The default parameter is \f[CB]false\f[R]. .RS .RE .TP .B \f[CB]\-fx=\f[R][\f[CB]true\f[R]|\f[CB]false\f[R]] Launches the script as a JavaFX application. The default parameter is \f[CB]false\f[R]. .RS .PP \f[B]Note:\f[R] .PP 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 \f[CB]\-\-module\-path\f[R] and \f[CB]\-\-add\-modules\f[R] options: .IP .nf \f[CB] jjs\ \-fx\ \-\-module\-path\ /SOMEDIR/javafx\-sdk\-11/lib\ \-\-add\-modules\ javafx.controls\ HelloWorld.js \f[R] .fi .PP The following example uses the \f[CB]jlink\f[R] 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 \f[CB]jjs\f[R] command: .IP .nf \f[CB] 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 \f[R] .fi .PP If you don\[aq]t explicitly specify the JavaFX modules, then the \f[CB]jjs\f[R] command prints a message and exits: .IP .nf \f[CB] jjs\ \-fx\ HelloWorld.js JavaFX\ is\ not\ available. \f[R] .fi .RE .TP .B \f[CB]\-h\f[R] or \f[CB]\-help\f[R] Prints the list of options and their descriptions. .RS .RE .TP .B \f[CB]\-\-language=\f[R][\f[CB]es5\f[R]|\f[CB]es6\f[R]] Specifies the ECMAScript language version. The default version is ES5. .RS .RE .TP .B \f[CB]\-\-module\-path\f[R] \f[I]path\f[R] Specifies where to find user Java modules. .RS .RE .TP .B \f[CB]\-ot=\f[R][\f[CB]true\f[R]|\f[CB]false\f[R]] or \f[CB]\-optimistic\-types=\f[R][\f[CB]true\f[R]|\f[CB]false\f[R]] Enables or disables optimistic type assumptions with deoptimizing recompilation. This makes the compiler try, for any program symbol whose type can\[aq]t be proven at compile time, to type it as narrowly and primitively as possible. If the runtime encounters an error because the symbol type is too narrow, then a wider method is generated until a steady stage is reached. While this produces as optimal Java bytecode as possible, erroneous type guesses will lead to longer warmup. Optimistic typing is currently enabled by default, but it can be disabled for faster startup performance. The default parameter is \f[CB]true\f[R]. .RS .RE .TP .B \f[CB]\-scripting=\f[R][\f[CB]true\f[R]|\f[CB]false\f[R]] Enables a shell scripting features. The default parameter is \f[CB]true\f[R]. .RS .RE .TP .B \f[CB]\-strict=\f[R][\f[CB]true\f[R]|\f[CB]false\f[R]] Enables a strict mode, which enforces stronger adherence to the standard (ECMAScript Edition 5.1), making it easier to detect common coding errors. The default parameter is \f[CB]false\f[R]. .RS .RE .TP .B \f[CB]\-t=\f[R]\f[I]zone\f[R] or \f[CB]\-timezone=\f[R]\f[I]zone\f[R] Sets the specified time zone for script execution. It overrides the time zone set in the OS and used by the \f[CB]Date\f[R] object. The default \f[I]zone\f[R] is \f[CB]America/Los_Angeles\f[R]. .RS .RE .TP .B \f[CB]\-v=\f[R][\f[CB]true\f[R]|\f[CB]false\f[R]] or\f[CB]\-version=\f[R][\f[CB]true\f[R]|\f[CB]false\f[R]] Prints the Nashorn version string. The default parameter is \f[CB]false\f[R]. .RS .RE .SH EXAMPLE OF RUNNING A SCRIPT WITH NASHORN .IP .nf \f[CB] jjs\ script.js \f[R] .fi .SH EXAMPLE OF RUNNING NASHORN IN INTERACTIVE MODE .IP .nf \f[CB] >>\ jjs jjs>\ println("Hello,\ World!") Hello,\ World! jjs>\ quit() >> \f[R] .fi .SH EXAMPLE OF PASSING ARGUMENTS TO NASHORN .IP .nf \f[CB] >>\ jjs\ \-\-\ a\ b\ c jjs>\ arguments.join(",\ ") a,\ b,\ c jjs> \f[R] .fi