External program execution in Java under windows
By Angsuman Chakraborty, Gaea News NetworkMonday, January 12, 2004
Question? Amitava Ghosh wrote at caljug:
Dear all,
I am trying to call an executable(written in C++) inside a java code through a
batch file(where the parameters for the C++ executable are stored).
When I am using
Process p = Runtime.getRunTime().exec(”cppexe.bat”)
it is working fine but when I am using start to run the batch process in a new window as in
Process p = Runtime.getRuntime().exec(”start cppexe.bat”)
I am getting an IOException Cannot create process etc etc
Answer: start is a command of cmd.exe (under Windows NT/2000 etc.). So you should run it instead:
Process p = Runtime.getRuntime().exec(”cmd /c start cppexe.bat”);
|
July 29, 2007: 11:00 am
hey thank u very much |
|
December 3, 2004: 6:16 pm
You can invoke start if you prefix it with cmd.exe, essentially then cmd.exe is the command and the rest are parameters. However why would you need to do start? > To run the Windows command interpreter, execute either command.com or cmd.exe, depending on the Windows operating system you use. Listing 4.5 runs a copy of the Windows command interpreter and then executes the user-supplied command (e.g., dir). Yes, you can do re-directions using the same trick mentioned above. Actually the url you supplied gives the above solutions too. |
|
Olivier |
February 29, 2004: 10:04 pm
Runtime.exec() is not a command line! |
Radha krishnan