0

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 2

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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.
For that I would use a Properties file for input and output. docs.oracle.com/javase/tutorial/essential/environment/…
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.