Error while runing a executable from JAVA

Hi,

I am trying to run a exe file from Java...I am geting the following exception

*******************************

java.io.IOException: CreateProcess: BOP.exe -e GT13E2M_E32_G21 error=2

at java.lang.ProcessImpl.create(Native Method)

at java.lang.ProcessImpl.<init>(Unknown Source)

at java.lang.ProcessImpl.start(Unknown Source)

at java.lang.ProcessBuilder.start(Unknown Source)

at java.lang.Runtime.exec(Unknown Source)

at java.lang.Runtime.exec(Unknown Source)

at afops.appActions.simulation.run.BOPSolver.runBOP(BOPSolver.java:37)

at afops.actions.SimulationStartAction.startRunForBasicBDDNormalCalc(SimulationStartAction.java:227)

at afops.actions.SimulationStartAction.actionPerformed(SimulationStartAction.java:105)

at afops.components.MyToolbar$EventRedirector.actionPerformed(MyToolbar.java:198)

************************************************************************

Following the piece of code

String workingDir = BenchConstants.workDir

+ BenchConstants.separator

+ ownedFrom.getDataBlock().getGTdir();

String command ="BOP.exe -e "+ownedFrom.getDataBlock().getGTdir().trim();

//String command = workingDir + BenchConstants.separator

//+ "BOP.exe -e " +workingDir + BenchConstants.separator +ownedFrom.getDataBlock().getGTdir();

File dir =new File(workingDir);

Runtime rt = Runtime.getRuntime();

String line;

String errLine;

System.out.println("Run Command string is : "+command);

Process pr = rt.exec(command,null,dir);

Here File object dir points to the Dir where the exe file is located and where the command to be run.....

Thanks & regards

Karthik

[1903 byte] By [java_karthika] at [2007-11-26 17:38:40]
# 1

'dir' only represents the working directory of the process, it has no bearing on where the executable is looked for. So if the executable isn't on your PATH (or one or two other well-known places) it won't get found.

To do what you want, you need to specify a full path to the exe - in this case converting 'dir' to a string and pre-pending it to the exe name should do the trick.

dannyyatesa at 2007-7-9 0:06:50 > top of Java-index,Core,Core APIs...