Angsuman's Java Blog

News and views from my perspective as a Chief Software Architect and CEO. Focused on Java and Web Technologies.

Sunday, April 07, 2002

Runtime.exec in Java Tip
> 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

start is a command of cmd. So run it instead:
Process p = Runtime.getRuntime().exec("cmd /c start cppexe.bat");

How to create lnk files, a close friend asked me today.

My thoughts:
Sample VB code is in
Another simpler option may be to just create a batch file (.bat) file which the users and double-click to run the application (same as a lnk file).
Creating it is much simpler. Create a file with .bat extension and write the same command as you would while running it from comand line.