如何在脚本结束时关闭jshell? [英] How to shutdown jshell at the end of the script?
本文介绍了如何在脚本结束时关闭jshell?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何指示 jshell
在脚本结尾处终止,类似于其他语言的解释器,例如 python3
或节点
?
How to instruct jshell
to terminate at the end of the script similarly to interpreters of other languages like for example python3
or node
?
以下命令
./jshell -q /tmp/shell.java
带脚本 /tmp/shell.java
System.out.println("Hello world");
打印
Hello world
jshell>
并等待进一步的命令。我希望它立即停止在文件的末尾。
and waits for further commands. I'd like it to stop immediately at the end of the file.
我正在寻找比更优雅的东西System.exit(0 );
在脚本的末尾。
I'm looking for something more elegant than System.exit(0);
at the end of the script.
推荐答案
在脚本中,使用jshell命令 /出口
。
这将在脚本结束时退出jshell。
Inside the script, use the jshell command /exit
.
This will exit jshell at the end of your script.
这篇关于如何在脚本结束时关闭jshell?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文