1JJS(1) JDK Commands JJS(1)
2
3
4
6 jjs - command-line tool to invoke the Nashorn engine
7
9 Note: The jjs tool and the Nashorn engine are deprecated in JDK 11 in
10 preparation for removal in a future release.
11
12 jjs [options] script-files [-- arguments]
13
14 options
15 This represents one or more options of the jjs command, separat‐
16 ed by spaces. See Options for the jjs Command.
17
18 script-files
19 This represents one or more script files that you want to inter‐
20 pret using the Nashorn engine, separated by spaces. If no files
21 are specified, then an interactive shell is started.
22
23 arguments
24 All values after the double hyphen marker (--) are passed
25 through to the script or the interactive shell as arguments.
26 These values can be accessed by using the arguments property.
27
29 The jjs command-line tool is used to invoke the Nashorn engine. You
30 can use it to interpret one or several script files, or to run an in‐
31 teractive shell.
32
34 The options of the jjs command control the conditions under which
35 scripts are interpreted by Nashorn engine.
36
37 -Dname=value
38 Sets a system property to be passed to the script by assigning a
39 value to a property name. The following example shows how to
40 invoke Nashorn engine in interactive mode and assign myValue to
41 the property named myKey:
42
43 >> jjs -DmyKey=myValue
44 jjs> java.lang.System.getProperty("myKey")
45 myValue
46 jjs>
47
48 This option can be repeated to set multiple properties.
49
50 --add-modules modules
51 Specifies the root user Java modules.
52
53 -cp path or -classpath path
54 Specifies the path to the supporting class files. To set multi‐
55 ple paths, the option can be repeated, or you can separate each
56 path with the following character:
57
58 · Oracle Solaris, Linux, and OS X: Colon (:)
59
60 · Windows: Semicolon (;)
61
62 -doe=[true|false] or -dump-on-error=[true|false]
63 Provides a full stack trace when an error occurs. By default,
64 only a brief error message is printed. The default parameter is
65 false.
66
67 -fv=[true|false] or -fullversion=[true|false]
68 Prints the full Nashorn version string. The default parameter
69 is false.
70
71 -fx=[true|false]
72 Launches the script as a JavaFX application. The default param‐
73 eter is false.
74
75 Note:
76
77 You must explicitly add the JavaFX modules to launch the script
78 as a JavaFX application. The following example specifies the
79 location of the JavaFX modules and adds them with the --mod‐
80 ule-path and --add-modules options:
81
82 jjs -fx --module-path /SOMEDIR/javafx-sdk-11/lib --add-modules javafx.controls HelloWorld.js
83
84 The following example uses the jlink command to create a custom
85 runtime image that contains the JavaFX modules. The example
86 then launches a script as a JavaFX application without specify‐
87 ing the JavaFX modules in the jjs command:
88
89 jlink --module-path /SOMEDIR/javafx-jmods-11 --add-modules jdk.scripting.nashorn,jdk.scripting.nashorn.shell,javafx.controls --output /SOMEDIR/myjdk
90
91 /SOMEDIR/myjdk/bin/jjs -fx HelloWorld.js
92
93 If you don't explicitly specify the JavaFX modules, then the jjs
94 command prints a message and exits:
95
96 jjs -fx HelloWorld.js
97
98 JavaFX is not available.
99
100 -h or -help
101 Prints the list of options and their descriptions.
102
103 --language=[es5|es6]
104 Specifies the ECMAScript language version. The default version
105 is ES5.
106
107 --module-path path
108 Specifies where to find user Java modules.
109
110 -ot=[true|false] or -optimistic-types=[true|false]
111 Enables or disables optimistic type assumptions with deoptimiz‐
112 ing recompilation. This makes the compiler try, for any program
113 symbol whose type can't be proven at compile time, to type it as
114 narrowly and primitively as possible. If the runtime encounters
115 an error because the symbol type is too narrow, then a wider
116 method is generated until a steady stage is reached. While this
117 produces as optimal Java bytecode as possible, erroneous type
118 guesses will lead to longer warmup. Optimistic typing is cur‐
119 rently enabled by default, but it can be disabled for faster
120 startup performance. The default parameter is true.
121
122 -scripting=[true|false]
123 Enables a shell scripting features. The default parameter is
124 true.
125
126 -strict=[true|false]
127 Enables a strict mode, which enforces stronger adherence to the
128 standard (ECMAScript Edition 5.1), making it easier to detect
129 common coding errors. The default parameter is false.
130
131 -t=zone or -timezone=zone
132 Sets the specified time zone for script execution. It overrides
133 the time zone set in the OS and used by the Date object. The
134 default zone is America/Los_Angeles.
135
136 -v=[true|false] or-version=[true|false]
137 Prints the Nashorn version string. The default parameter is
138 false.
139
141 jjs script.js
142
144 >> jjs
145 jjs> println("Hello, World!")
146 Hello, World!
147 jjs> quit()
148 >>
149
151 >> jjs -- a b c
152 jjs> arguments.join(", ")
153 a, b, c
154 jjs>
155
156
157
158JDK 14 2020 JJS(1)