Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 16-04-2009
Member
 
Join Date: Jan 2009
Posts: 289
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?
Reply With Quote
  #2  
Old 16-04-2009
Member
 
Join Date: Apr 2008
Posts: 2,001
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...!
Reply With Quote
  #3  
Old 16-04-2009
Member
 
Join Date: Feb 2008
Posts: 1,848
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...!
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "IOException while using ProcessBuilder class"
Thread Thread Starter Forum Replies Last Post
Upgrade Sony Ericsson Xperia Play Micro SD card from class 2 8GB to class 4 32GB Aaryan2011 Portable Devices 8 08-10-2011 11:06 PM
Problem in java.io.IOException GlassFish Software Development 4 25-02-2010 03:31 AM
How to initialize a derived class with an instance of the base class in c#? KAIRU26 Software Development 5 12-02-2010 06:23 PM
Ultra solid drives:Imation M-Class and S-Class Regina Portable Devices 1 03-04-2009 10:34 AM
Good news for CBSE CLASS X & CLASS IX - visit learnnext surya_expert Education Career and Job Discussions 0 13-12-2008 12:09 PM


All times are GMT +5.5. The time now is 12:41 AM.