Reputation: 11
I have created a jar file called test.jar under C:\jars. I have JAR file under the same location named run.bat and it contains the below code -
@echo off
set exec_path=C:\jars java -cp %exec_path%/test.jar; com.mycomp.myapp.MyProgram "%1"%*
@echo on
It is running successfully from command prompt with parameters.
Now I would like to run it from another JAVA program. Please suggest.
Thanks!
Upvotes: 1
Views: 5257
Reputation: 35011
I've encountered this issue before. The answer is that you have to run cmd.exe or bash or whatever shell you've got, then feed in the command to that process via the process input/output streams.
Process p = Runtime.getRuntime().exec("cmd");
p.getOutputStream().write("mybatch.bat\n");
Upvotes: 1