How can the Java program return values that the batch file can see? What other options are there to accomplish this task, without using batch file?
2 Answers
When you call System.exit(n) the value is the exit code or ERRORLEVEL which the batch script can use.
You can also read the output of the program or the contents of a file written.
2 Comments
robrochta
Is it possible to pass variables names (20 diffrent) from Batch to Java code, make Java search for variables' values, and return values to Batch file? What would be better solution for that? Thank You.
Peter Lawrey
For that I would use a Properties file for input and output. docs.oracle.com/javase/tutorial/essential/environment/…
You can redirect System.out to file
PrintStream out = new PrintStream(new FileOutputStream("output.txt"));
System.setOut(out);
or use some logging library like log4j