Reputation:
I have asked this question before. I am having the following requirement.
I have the following code that does not meet the requirement. Please tell me where I have made a mistake
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec(command);
//pr.exitValue();
//wait(10000);
pr.waitFor();
pr.destroy();
I have used the waitFor that does not work. How can I give a delay for about 15 minutes after executing the batch file
Upvotes: 0
Views: 920
Reputation: 29669
Your question did not mention giving a delay in Java. You imply that the delay should be in the batch file after the Java program executes. Therefore, you can configure it for any amount of time. Here is a 20 second example:
@ECHO off
REM.-- End of application
:: do something here
GOTO :END
:: you could put functions here
:END
FOR /l %%a in (20,-1,1) do (TITLE %title% -- closing in %%as&ping -n 2 -w 1 127.0.0.1>NUL)
TITLE Press any key to close the application&ECHO.&GOTO:EOF
PAUSE>nul
Upvotes: 0
Reputation: 9058
If you do not have threads reading the stdIO from the batch process, the batch process can block. Even if you are not interested you still ned to read it and discard it. Then your wait for has a better change of working.
Upvotes: 1
Reputation: 61526
A suggestion: grab the output and error streams and see what they are printing out. You may see that there is an error happening with the batch file making it return sooner than you expect.
Upvotes: 0
Reputation: 2671
I'm not sure what you want, but with
Thread.sleep(900000);
you can wait for 15 minutes.
Upvotes: 0