简体   繁体   English

如何从批处理文件中的Java程序中获取退出状态

[英]How to get exit status from a Java program in a batch file

I'm newbie in batch programming (I don't know much about batch files). 我是批处理编程的新手(我对批处理文件了解不多)。 My boss has asked me to write a batch file that runs a Java application. 我的老板要我写一个运行Java应用程序的批处理文件。 The batch file has something like this: 批处理文件具有以下内容:

echo ロックテーブル削除

java -cp n:\kanesin.root\bin\Sys.Boundary.BatchMain.jar /JobID:BCM0020  
if not ERRORLEVEL 0 (
    echo Teiji_H01.bat BCM0020 > rerun.bat
    goto ERROREXIT
)

but I don't know how the Java application sends the ERRORLEVEL to this batch file. 但我不知道Java应用程序如何将ERRORLEVEL发送到此批处理文件。 Do I have to return an integer value, or use System.exit(number); 我是否必须返回一个整数值,或使用System.exit(number); ?

Do I have to return an integer value, or use System.exit(number); 我是否必须返回一个整数值,或使用System.exit(number); ?

Yes. 是。 You set that by using System.exit(int) which (per the Javadoc) 你通过使用System.exit(int)它(根据Javadoc)

Terminates the currently running Java Virtual Machine. 终止当前运行的Java虚拟机。 The argument serves as a status code; 该参数用作状态代码; by convention, a nonzero status code indicates abnormal termination. 按照惯例,非零状态代码表示异常终止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM