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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.