How to exit jshell in Java?

To exit JShell, type /exit.
I stayed in the JShell for a few minutes, executing things like exit, CTRL + c, end and q! , q, quit all fail. The correct syntax for exiting or quitting JShell is /exit.

Terminal

C:\Users\mkyong>jshell
|  Welcome to JShell -- Version 11.0.1
|  For an introduction type: /help intro

jshell> exit
|  Error:
|  cannot find symbol
|    symbol:   variable exit
|  exit
|  ^--^

jshell> q
|  Error:
|  cannot find symbol
|    symbol:   variable q
|  q
|  ^

jshell> quit
|  Error:
|  cannot find symbol
|    symbol:   variable quit
|  quit
|  ^--^

jshell> end
|  Error:
|  cannot find symbol
|    symbol:   variable end
|  end
|  ^-^

jshell>

Finally, /exit.

Terminal

jshell> /exit
|  Goodbye

reference
Wikipedia – JShellOracle – JShell Introduction

 

Tags:
Java 9
Jshell

 

 

Translated from: https://mkyong.com/java/how-to-exit-jshell-in-java/

Read More: