In this program i am trying to execute a batch file using java.
output "wait completed" is printed even before the process p completed ! why is that so? it is working well with eclipse not working in netbeans i m using netbeans 6.9 with jdk 1.6
Nitin Surana wrote:I also had the same problem, long time ago and was unable to solve. Any help is greatly appreciated.
I have done a small work around and its working as of now its not a legal solution
and remove p.waitFor
add small code at the end of the batch file
when work is over batch file executes the exit statement and it will return controll to the program then p.getInputStream().read() will return -1 this will indicate end of execution untill -1 is got the main thread will wait for process. "This worked for me" might work for you also