- Loading...
Nashorn implements ECMAScript 5.1 specification http://www.ecma-international.org/ecma-262/5.1/
Nashorn implements number of syntactic and API extensions as well. This page describes syntax and API extensions of nashorn implementation.
...
| Code Block | ||
|---|---|---|
| ||
loadWithNewGlobal({
script: "foo = 333; print(foo)",
name: "test"
});
// prints undefined as "foo" is defined in the new global and not here
print(typeof foo); |
exit and quit functions
These synonymous functions exit the current process with specified (optional) exit code.
| Code Block | ||
|---|---|---|
| ||
exit(1); // exit with given exit code
exit(); // exit 0
quit(2); // exit with given exit code
quit(); // exit 0 |
Packages, java, javax, javafx, com, edu
Packages and friends are there to support java package, class access from script. The properties of the Packages variable are all the top-level Java packages, such as java and javax etc.
| Code Block | ||
|---|---|---|
| ||
var Vector = Packages.java.util.Vector;
// but short-cuts defined for important package prefixes like
// Packages.java, Packages.javax, Packages.com, Packages.edu, Packages.javafx
var JFrame = javax.swing.JFrame;
var List = java.util.List; |