You cannot use /exitjshell with a non-zero error code to exit a regular session. See https://bugs.openjdk.java.net/browse/JDK-8185840 for more details .
jshell (.. vm), System.exit(1) vm .
runnig DOS:
jshell
| Welcome to JShell
| For an introduction type: /help intro
jshell> System.exit(123)
echo Exit Code is %errorlevel%
Exit Code is 123
. http://mail.openjdk.java.net/pipermail/kulla-dev/2017-August/002062.html.
Java 10
Java 10 /exit, . , . . http://mail.openjdk.java.net/pipermail/kulla-dev/2017-November/002129.html.
/exit jdk-10 + ea-33:
| Welcome to JShell
| For an introduction type: /help intro
jshell> /help exit
|
| /exit
|
| Leave the jshell tool. No work is saved.
| Save any work before using this command
|
| /exit
| Leave the jshell tool. The exit status is zero.
|
| /exit <integer-expression-snippet>
| Evaluate the snippet. If the snippet fails or is not an integer expression,
| display the error. Otherwise leave the jshell tool with the
| value of the expression as the exit status
jshell> /exit 123
| Goodbye (123)
source
share