Using Nashorn as a command-line tool

The Nashorn executable file, jjs.exe, resides in the bin folder. To access it, you can navigate to that folder or, if your system path is set up appropriately, you can launch into the shell by entering the jjs command in a Terminal / Command Prompt window on your system:

Here, you can see an open terminal window that first checks the version of Java and then uses the jjs -version command to launch the Nashorn shell. In this example, both Java and Nashorn are version 1.8.0.121. Alternatively, we can simply launch Nashorn with the jjs command, and the shell will open without the version identification:

Get Java 9: Building Robust Modular Applications now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.