Documentation Contents
Java Platform, Standard Edition Tools Reference
Contents    Previous   

jjs

Invokes the Nashorn engine.

Synopsis

jjs [options] [script-files] [-- arguments]
options

One or more options of the jjs command, separated by spaces. For more information, see Options.

script-files

One or more script files which you want to interpret using Nashorn, separated by spaces. If no files are specified, an interactive shell is started.

arguments

All values after the double hyphen marker (--) are passed through to the script or the interactive shell as arguments. These values can be accessed by using the arguments property (see Example 3).

Description

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.

Options

The options of the jjs command control the conditions under which scripts are interpreted by Nashorn.

-ccs=size
--class-cache-size=size

Sets the class cache size (in bytes). Append the letter k or K to indicate kilobytes (KB), m or M to indicate megabytes (MB), g or G 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):

-css=100
-css=1k
-co
--compile-only

Compiles the script without running it.

-cp path
--classpath path

Specifies 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 (:).

-Dname=value

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 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.

-d=path
--dump-debug-dir=path

Specifies the path to the directory where class files are dumped.

--debug-lines

Generates a line number table in the class file. By default, this option is enabled. To disable it, specify --debug-lines=false.

--debug-locals

Generates a local variable table in the class file.

-doe
--dump-on-error

Provides a full stack trace when an error occurs. By default, only a brief error message is printed.

--early-lvalue-error

Reports invalid lvalue expressions as early errors (that is, when the code is parsed). By default, this option is enabled. To disable it, specify --early-lvalue-error=false. When disabled, invalid lvalue expressions will not be reported until the code is executed.

--empty-statements

Preserves empty statements in the Java abstract syntax tree.

-fv
--fullversion

Prints the full Nashorn version string.

--function-statement-error

Prints an error message when a function declaration is used as a statement.

--function-statement-warning

Prints a warning message when a function declaration is used as a statement.

-fx

Launches the script as a JavaFX application.

-h
-help

Prints the list of options and their descriptions.

-Joption

Passes the specified java 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:

>> jjs -J-Xmx4g
jjs> java.lang.Runtime.getRuntime().maxMemory()
3817799680
jjs>

This option can be repeated to pass multiple java command options.

--lazy-compilation

Enables lazy code generation strategies (that is, the entire script is not compiled at once). This option is experimental.

--loader-per-compile

Creates a new class loader per compile. By default, this option is enabled. To disable it, specify --loader-per-compile=false.

--log=subsystem:level

Performs logging at a given level for the specified subsystems. You can specify logging levels for multiple subsystems separating them with commas. For example:

--log=fields:finest,codegen:info
--package=name

Specifies the package to which generated class files are added.

--parse-only

Parses the code without compiling.

--print-ast

Prints the abstract syntax tree.

--print-code

Prints bytecode.

--print-lower-ast

Prints the lowered abstract syntax tree.

--print-lower-parse

Prints the lowered parse tree.

--print-no-newline

Forces other --print* options to print the output on one line.

--print-parse

Prints the parse tree.

--print-symbols

Prints the symbol table.

-pcs
--profile-callsites

Dumps callsite profile data.

-scripting

Enables shell scripting features.

--stderr=filename|stream|tty

Redirects the standard error stream to the specified file, stream (for example, to stdout), or text terminal.

--stdout=filename|stream|tty

Redirects the standard output stream to the specified file, stream (for example, to stderr), or text terminal.

-strict

Enables strict mode, which enforces stronger adherence to the standard (ECMAScript Edition 5.1), making it easier to detect common coding errors.

-t=zone
-timezone=zone

Sets the specified time zone for script execution. It overrides the time zone set in the OS and used by the Date object.

-tcs=parameter
--trace-callsites=parameter

Enables callsite trace mode. Possible parameters are the following:

miss

Trace callsite misses.

enterexit

Trace callsite enter/exit.

objects

Print object properties.

--verify-code

Verifies bytecode before running.

-v
-version

Prints the Nashorn version string.

-xhelp

Prints extended help for command-line options.

Examples

Example 1Running a Script with Nashorn
jjs script.js
Example 2Running Nashorn in Interactive Mode
>> jjs
jjs> println("Hello, World!")
Hello, World!
jjs> quit()
>>
Example 3Passing Arguments to Nashorn
>> jjs -- a b c
jjs> arguments.join(", ")
a, b, c
jjs>

See Also

jrunscript

Contents    Previous   

Oracle and/or its affiliates Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.
Contact Us