Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 java 来运行用 Rhino 编写的命令行实用程序,但如果出现错误,我需要将该错误返回到 shell 以便停止处理。如何将错误代码从 Rhino 传递回 shell?
你可以使用
java.lang.System.exit(1);
执行java.lang.System.exit(1)可能会产生意想不到的结果,例如整个环境或应用程序退出(例如 HPOO)。
java.lang.System.exit(1)