25.12 Summary of JShell Commands

Figure 25.6 shows the basic JShell commands. Many of these commands have been presented throughout this chapter. Others are discussed in this section.

Fig. 25.6

Command Description
/help or /? Displays JShell’s list of commands.
/help intro Displays a brief introduction to JShell.
/help shortcuts Displays a description of several JShell shortcut keys.
/list By default, lists the valid snippets you’ve entered in the current session. To list all snippets, use /list -all.
/! Recalls and re-evaluates the last snippet.
/id Recalls and re-evaluates the snippet with the specified id.
/-n Recalls and re-evaluates a prior snippet—for n, 1 is the last snippet, 2 is the second-to-last, etc.
/edit By ...

Get Java How to Program, Early Objects, 11th Edition 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.