TechArena Community

TechArena Community (http://forums.techarena.in/)
-   Software Development (http://forums.techarena.in/software-development/)
-   -   IOException while using ProcessBuilder class (http://forums.techarena.in/software-development/1162621.htm)

Patio 16-04-2009 09:21 PM

IOException while using ProcessBuilder class
 
I tried to start a program within a Java application using the ProcessBuilder class. This is the first time I'm using ProcessBuilder so I have no idea about what is happening...! Here is my code:

Code:

static void connectToHost(String Host) {
ProcessBuilder pb = new ProcessBuilder("connect.exe"), Host);
Map<String, String> env = pb.environment();
env.put("SHELLWIDTH", "64");
pb.directory(new File("C:\\MyProgram\\ExApp\\shell"));
 
try (
Process p = pb.start();
} catch (IOException ex) {
Logger.getLogger(ShellUtil.class.getName()).log(Level.SEVERE, null, ex);
}
}


When i use this method I get an IOException which says "Cannot run program "connect.exe" (in directory "C:\MyProgram\ExApp\shell"): CreateProcess error=2, The system couldn't find the specified file" Can anyone help me out with this?

kelfro 16-04-2009 10:16 PM

Re: IOException while using ProcessBuilder class
 
Hey!
Why don't you just provide the full path to connect.exe, rather than just connect.exe around with the system PATH? May be that could help...! Well i'm not at all good at coding...! Anyways, All the best...!

MindSpace 16-04-2009 10:17 PM

Re: IOException while using ProcessBuilder class
 
Hey!
I guess the working directory is not used to search for the executable connect.exe . connect.exe must be located in a directory that is on the 'path'. Well try it out and post if it works....! All the best...!


All times are GMT +5.5. The time now is 02:47 PM.