1

In a batch file, I am trying to wait for a java program to finish before continuing. The program has a GUI interface.

So far I have tried both (with java and javaw)

javaw -jar program.jar
start "" /wait javaw -jar program.jar
start "" /wait /b javaw -jar program.jar
call javaw -jar program.jar /wait

Both continue on without waiting for the program to finish.

CrazyJane
  • 63
  • 10
  • Unfortunately, after diving into the code for the program I was launching (not controlled by me) I found that the program starts new processes to perform the tasks and exits without waiting for those processes, which caused my script to continue before what I thought it was supposed to wait for. Thanks for the advice and clarifications on things. – CrazyJane Nov 26 '19 at 19:21

1 Answers1

0

Javaw is meant to run in GUI and detaches the console. Use java instead - and do not prefix with start or call - they will run the stuff in the background again. So your call should look like

java -jar program.jar

See also What is the difference between 'java', 'javaw', and 'javaws'?

Queeg
  • 7,748
  • 1
  • 16
  • 42