简体   繁体   中英

Understanding syntax for running Java program in command line

I'm trying to understand this batch job file, there are two and the first is returning an exit code of 0:

set JAVA_HOME="C:\Program Files(x86)\Java\jre1.8.0_221\bin"

%JAVA_HOME%\java -Xms125M -Xmx512M -Djava.ext.dirs=lib org.pg.test.ListOutput > output.txt 2>exception.txt

And this second one is returning an exit code of 1:

set JAVA_HOME="C:\Program Files(x86)\Java\jre1.8.0_221\bin"

%JAVA_HOME%\java -Xms125M -Xmx512M -Djava.ext.dirs=lib org.pg.test.ListOutput 1 0 > output.txt 2>exception.txt

What does the 1 & 0 after the file name mean exactly? Why is this making it return an exit code 1?

Both files run normally, with a successful output in output.txt.

Trying to google the exact syntax this is in (batch files were not written by me) but maybe I'm searching for the wrong thing.

The documentation for the java command is found

  • here for JDK/JRE version 18 (a fairly recent version), and
  • here for JDK/JRE version 1.8 for Windows, which appears to be what you're using.

The 1 and the 0 after the class name are arguments that will be passed to the Java program when it runs. As for why this causes the program to exit with a particular exit code, that depends on what the program does. It's impossible to answer that without seeing the source code of the program.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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