I tried to write some jshell scripts. When an exception is thrown, jshell continues to execute the next line.
How can I make my scripts behave like regular Java programs?
Edit : I just run it as jshell SCR.jsh
.
Using throw new Exception()
or 1/0
does not prevent the execution of the next line.
The script includes the following sentence:
System.out.println(1/0)
System.out.println("foo")
/exit
I thought the second line was unattainable. This is what I expected. But after printing the exception is printed foo
.
source
share