blob: 47b5602ac1040361c6a132b2a3cfff4ab8b540a3 [file] [log] [blame]
rgallardb6435452013-11-25 20:19:02 -08001'\" t
2.\" Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
3.\"
4.\" DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5.\"
6.\" This code is free software; you can redistribute it and/or modify it
7.\" under the terms of the GNU General Public License version 2 only, as
8.\" published by the Free Software Foundation.
9.\"
10.\" This code is distributed in the hope that it will be useful, but WITHOUT
11.\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12.\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13.\" version 2 for more details (a copy is included in the LICENSE file that
14.\" accompanied this code).
15.\"
16.\" You should have received a copy of the GNU General Public License version
17.\" 2 along with this work; if not, write to the Free Software Foundation,
18.\" Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19.\"
20.\" Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21.\" or visit www.oracle.com if you need additional information or have any
22.\" questions.
23.\"
24.\" Arch: generic
25.\" Software: JDK 8
26.\" Date: 21 November 2013
27.\" SectDesc: Basic Tools
28.\" Title: jjs.1
29.\"
30.if n .pl 99999
31.TH jjs 1 "21 November 2013" "JDK 8" "Basic Tools"
32.\" -----------------------------------------------------------------
33.\" * Define some portability stuff
34.\" -----------------------------------------------------------------
35.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
36.\" http://bugs.debian.org/507673
37.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
38.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
39.ie \n(.g .ds Aq \(aq
40.el .ds Aq '
41.\" -----------------------------------------------------------------
42.\" * set default formatting
43.\" -----------------------------------------------------------------
44.\" disable hyphenation
45.nh
46.\" disable justification (adjust text to left margin only)
47.ad l
48.\" -----------------------------------------------------------------
49.\" * MAIN CONTENT STARTS HERE *
50.\" -----------------------------------------------------------------
51
52.SH NAME
53jjs \- Invokes the Nashorn engine\&.
54.SH SYNOPSIS
55.sp
56.nf
57\f3\fBjjs\fR [\fIoptions\fR] [\fIscript\-files\fR] [\-\- \fIarguments\fR]\fP
58.fi
59.sp
60.TP
61\fIoptions\fR
62One or more options of the \f3jjs\fR command, separated by spaces\&. For more information, see Options\&.
63.TP
64\fIscript-files\fR
65One or more script files which you want to interpret using Nashorn, separated by spaces\&. If no files are specified, an interactive shell is started\&.
66.TP
67\fIarguments\fR
68All values after the double hyphen marker (\f3--\fR) are passed through to the script or the interactive shell as arguments\&. These values can be accessed by using the \f3arguments\fR property (see )\&.
69.SH DESCRIPTION
70The \f3jjs\fR 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\&.
71.SH OPTIONS
72The options of the \f3jjs\fR command control the conditions under which scripts are interpreted by Nashorn\&.
73.TP
74-ccs=\fIsize\fR , --class-cache-size=\fIsize\fR
75.br
76Sets the class cache size (in bytes)\&. Append the letter \f3k\fR or \f3K\fR to indicate kilobytes (KB), \f3m\fR or \f3M\fR to indicate megabytes (MB), \f3g\fR or \f3G\fR to indicate gigabytes (GB)\&. By default, the class cache size is set to 50 bytes\&. The following example shows how to set it to 1024 bytes (1 KB):
77.sp
78.nf
79\f3\-css=100\fP
80.fi
81.nf
82\f3\-css=1k\fP
83.fi
84.nf
85\f3\fR
86.fi
87.sp
88
89.TP
90-co, --compile-only
91.br
92Compiles the script without running it\&.
93.TP
94-cp \fIpath\fR , --classpath \fIpath\fR
95.br
96Specifies the path to the supporting class files To set multiple paths, the option can be repeated, or you can separate each path with a colon (:)\&.
97.TP
98-D\fIname\fR=\fIvalue\fR
99.br
100Sets 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 in interactive mode and assign \f3myValue\fR to the property named \f3myKey\fR:
101.sp
102.nf
103\f3>> \fIjjs \-DmyKey=myValue\fR\fP
104.fi
105.nf
106\f3jjs> \fIjava\&.lang\&.System\&.getProperty("myKey")\fR\fP
107.fi
108.nf
109\f3myValue\fP
110.fi
111.nf
112\f3jjs>\fP
113.fi
114.nf
115\f3\fR
116.fi
117.sp
118
119
120This option can be repeated to set multiple properties\&.
121.TP
122-d=\fIpath\fR , --dump-debug-dir=\fIpath\fR
123.br
124Specifies the path to the directory where class files are dumped\&.
125.TP
126--debug-lines
127.br
128Generates a line number table in the class file\&. By default, this option is enabled\&. To disable it, specify \f3--debug-lines=false\fR\&.
129.TP
130--debug-locals
131.br
132Generates a local variable table in the class file\&.
133.TP
134-doe, --dump-on-error
135.br
136Provides a full stack trace when an arror occurs\&. By default, only a brief error message is printed\&.
137.TP
138--early-lvalue-error
139.br
140Reports invalid lvalue expressions as early errors (that is, when the code is parsed)\&. By default, this option is enabled\&. To disable it, specify \f3--early-lvalue-error=false\fR\&. When disabled, invalid lvalue expressions will not be reported until the code is executed\&.
141.TP
142--empty-statements
143.br
144Preserves empty statements in the Java abstract syntax tree\&.
145.TP
146-fv, --fullversion
147.br
148Prints the full Nashorn version string\&.
149.TP
150--function-statement-error
151.br
152Prints an error message when a function declaration is used as a statement\&.
153.TP
154--function-statement-warning
155.br
156Prints a warning message when a function declaration is used as a statement\&.
157.TP
158-fx
159.br
160Launches the script as a JavaFX application\&.
161.TP
162-h, -help
163.br
164Prints the list of options and their descriptions\&.
165.TP
166-J\fIoption\fR
167.br
168Passes the specified \f3java\fR launcher option to the JVM\&. The following example shows how to invoke Nashorn in interactive mode and set the maximum memory used by the JVM to 4 GB:
169.sp
170.nf
171\f3>> \fIjjs \-J\-Xmx4g\fR\fP
172.fi
173.nf
174\f3jjs> \fIjava\&.lang\&.Runtime\&.getRuntime()\&.maxMemory()\fR\fP
175.fi
176.nf
177\f33817799680\fP
178.fi
179.nf
180\f3jjs>\fP
181.fi
182.nf
183\f3\fR
184.fi
185.sp
186
187
188This option can be repeated to pass multiple \f3java\fR command options\&.
189.TP
190--lazy-compilation
191.br
192Enables lazy code generation strategies (that is, the entire script is not compiled at once)\&. This option is experimental\&.
193.TP
194--loader-per-compile
195.br
196Creates a new class loader per compile\&. By default, this option is enabled\&. To disable it, specify \f3--loader-per-compile=false\fR\&.
197.TP
198--log=\fIsubsystem\fR:\fIlevel\fR
199.br
200Performs logging at a given level for the specified subsystems\&. You can specify logging levels for multiple subsystems separating them with commas\&. For example:
201.sp
202.nf
203\f3\-\-log=fields:finest,codegen:info\fP
204.fi
205.nf
206\f3\fR
207.fi
208.sp
209
210.TP
211--package=\fIname\fR
212.br
213Specifies the package to which generated class files are added\&.
214.TP
215--parse-only
216.br
217Parses the code without compiling\&.
218.TP
219--print-ast
220.br
221Prints the abstract syntax tree\&.
222.TP
223--print-code
224.br
225Prints bytecode\&.
226.TP
227--print-lower-ast
228.br
229Prints the lowered abstract syntax tree\&.
230.TP
231--print-lower-parse
232.br
233Prints the lowered parse tree\&.
234.TP
235--print-no-newline
236.br
237Forces other \f3--print*\fR options to print the output on one line\&.
238.TP
239--print-parse
240.br
241Prints the parse tree\&.
242.TP
243--print-symbols
244.br
245Prints the symbol table\&.
246.TP
247-pcs, --profile-callsites
248.br
249Dumps callsite profile data\&.
250.TP
251-scripting
252.br
253Enables shell scripting features\&.
254.TP
255--stderr=\fIfilename\fR|\fIstream\fR|\fItty\fR
256.br
257Redirects the standard error stream to the specified file, stream (for example, to \f3stdout\fR), or text terminal\&.
258.TP
259--stdout=\fIfilename\fR|\fIstream\fR|\fItty\fR
260.br
261Redirects the standard output stream to the specified file, stream (for example, to \f3stderr\fR), or text terminal\&.
262.TP
263-strict
264.br
265Enables strict mode, which enforces stronger adherence to the standard (ECMAScript Edition 5\&.1), making it easier to detect common coding errors\&.
266.TP
267-t=\fIzone\fR , -timezone=\fIzone\fR
268.br
269Sets the specified time zone for script execution\&. It overrides the time zone set in the OS and used by the \f3Date\fR object\&.
270.TP
271-tcs=\fIparameter\fR , --trace-callsites=\fIparameter\fR
272.br
273Enables callsite trace mode\&. Possible parameters are the following:
274.RS
275.TP
276miss
277Trace callsite misses\&.
278.TP
279enterexit
280Trace callsite enter/exit\&.
281.TP
282objects
283Print object properties\&.
284.RE
285
286.TP
287--verify-code
288.br
289Verifies bytecode before running\&.
290.TP
291-v, -version
292.br
293Prints the Nashorn version string\&.
294.TP
295-xhelp
296.br
297Prints extended help for command-line options\&.
298.SH EXAMPLES
299\f3Example 1 Running a Script with Nashorn\fR
300.sp
301.nf
302\f3jjs script\&.js\fP
303.fi
304.nf
305\f3\fR
306.fi
307.sp
308\f3Example 2 Running Nashorn in Interactive Mode\fR
309.sp
310.nf
311\f3>> \fIjjs\fR\fP
312.fi
313.nf
314\f3jjs> \fIprintln("Hello, World!")\fR\fP
315.fi
316.nf
317\f3Hello, World!\fP
318.fi
319.nf
320\f3jjs> \fIquit()\fR\fP
321.fi
322.nf
323\f3>>\fP
324.fi
325.nf
326\f3\fR
327.fi
328.sp
329\f3Example 3 Passing Arguments to Nashorn\fR
330.sp
331.nf
332\f3>> \fIjjs \-\- a b c\fR\fP
333.fi
334.nf
335\f3jjs> \fIarguments\&.join(", ")\fR\fP
336.fi
337.nf
338\f3a, b, c\fP
339.fi
340.nf
341\f3jjs>\fP
342.fi
343.nf
344\f3\fR
345.fi
346.sp
347.SH SEE\ ALSO
348\f3jrunscript\fR
349.RE
350.br
351'pl 8.5i
352'bp