I've made a batch file which needs to open the browser at localhost and start a java program.
Simplified this currently is :
start "" http://localhost
java -start_java_program
This works fine but the browser is now already started before java is done starting the local server. So you get a not found page.
I can't execute the start
command after the java
command because the java keeps executing from the .bat file.
Ideally I would like to call start with like a 5 second delay and still keep executing the script and call java. So things as sleep and timeout won't work for me since java won't start as well than.
Does anybody know a way to do this?
Thanks!
This is basically Magoo's answer, but without the extra batch file. I also add the /B
option to the initial START command - there is no need for a second console to appear.
@echo off
start "" /b cmd /c "timeout /nobreak 10 >nul & start "" http://localhost"
echo java -start_java_program