How to shutdown jshell at the end of the script?

czerny :

How to instruct jshell to terminate at the end of the script similarly to interpreters of other languages like for example python3 or node?

Following command

./jshell -q /tmp/shell.java

with script /tmp/shell.java

System.out.println("Hello world");

prints

Hello world
jshell> 

and waits for further commands. I'd like it to stop immediately at the end of the file.

I'm looking for something more elegant than System.exit(0); at the end of the script.

Jay :

Inside the script, use the jshell command /exit. This will exit jshell at the end of your script.

Check this reference https://docs.oracle.com/javase/9/jshell/introduction-jshell.htm#JSHEL-GUID-465BA4F5-E77D-456F-BCB7-D826AC1E18AE

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=427263&siteId=1