where options are:
-e script-source
Executes script-source as a JavaScript script.-f script-filename
Reads filename specified by script-filename and executes it as a JavaScript script.-opt optLevel
The arguments object is an array containing the strings of all the arguments given at the command line when the shell was invoked.
Executing the help function will print usage and help messages.
Define an extension using the Java class named with the string argument className. Uses ScriptableObject.defineClass() to define the extension.
Load JavaScript source files named by string arguments. If multiple arguments are given, each file is read in and executed in turn.
Load and execute the class named by the string argument className. The class must be a class that implements the Script interface, as will any script compiled by jsc.
Evaluate and print expressions. Evaluates each expression, converts the result to a string, and prints it.
Quit shell. The shell will also quit in interactive mode if an end-of-file character is typed at the prompt.
Get or set JavaScript version number. If no argument is supplied, the current version number is returned. If an argument is supplied, it is expected to be one of 100, 110, 120, 130, or 140 to indicate JavaScript version 1.0, 1.1, 1.2, 1.3, or 1.4 respectively.
$ java org.mozilla.javascript.tools.shell.Main -e print('hi')
hi
$ java org.mozilla.javascript.tools.shell.Main
js> print('hi')
hi
js> 6*7
42
js> function f() {
return a;
}
js> var a = 34;
js> f()
34
js> quit()
$ cat echo.js
for (i in arguments) {
print(arguments[i])
}
$ java org.mozilla.javascript.tools.shell.Main echo.js foo bar
foo
bar
$