0

This is kind of a similar (not duplicate)to this question. It's different in the sense it's executed from Windows batch script and NOT UNIX shell script as the link states. execute jar return data to shell script

In my case, I have a runnable jar that is executed from command/batch script in Windows. I am using System.out.println in java to display the output onto the DOS window. How do I read it in onto a batch variable?

As the linked article states, the executable jar can't return a value as the main returns void.

yonikawa
  • 581
  • 1
  • 9
  • 32
  • 1
    Did you not see this: [Assign output of a program to a variable using a MS batch file](https://stackoverflow.com/questions/2323292/assign-output-of-a-program-to-a-variable-using-a-ms-batch-file) – Abra Jan 11 '22 at 17:26
  • @ab - thanks for the response. I did see that, but as my link suggest, the jar can't return any data only prints out to the console. So I need to find a way to read the data from the console using batch script. Updated my post with further details. – yonikawa Jan 11 '22 at 17:29
  • 1
    Any data that outputs to `CON` cannot be captured by a batch file. The output has to be written to Standard Output for a batch file to capture it. – Squashman Jan 11 '22 at 17:51
  • @Squashman - I am doing a System.out from java. Is it the same as Standard output? Sorry I am a newbie in batch stuff. :( – yonikawa Jan 11 '22 at 18:20

0 Answers0