Saving scripts

In addition to creating JShell scripts in external editors, we can create them within the JShell environment as well. When taking this approach, you will need to use the /save command to save your scripts. As you can see in the following screenshot, the /save command requires, at a minimum, a file name argument:

There are three options available to you with the /save command:

  • The -all option can be used to save the source of all snippets to the specified file.
  • The -history option saves a sequential history of all commands and snippets you entered since JShell was launched. JShell's ability to perform this operation informs ...

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.