Main Tutorials

How to exit JShell in Java?

To exit JShell, type /exit.

I stuck in JShell for minutes, commands like exit, ctrl + c, end, q!, q, quit all failed, the correct syntax to quit or exit the 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

References

About Author

author image
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

Subscribe
Notify of
4 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Juliano Canuto
2 years ago

I can’t believe that I had to read an article to find out how to exit the jshell xD Thanks for sharing.

Mark
3 years ago

Also ctrl + d works!

Brandon M
4 months ago

what about /quit