This discussion is archived
4 Replies Latest reply: May 15, 2013 5:02 AM by gimbal2 RSS

create process error 2 this system cannot find the file specified.

943617 Newbie
Currently Being Moderated
import java.io.IOException;

public class ProcessRuntime
{
     public static void main(String[] args) throws IOException, InterruptedException
     {
          String process = "C:/Program Files/PostgreSQL/9.2/bin/psql.exe -U postgres -V postgres";
if (true) System.out.println(process);

// Hold control over Runtime Enviroment
Runtime run = Runtime.getRuntime();

String REDIRECT = ">";
String fileName = null;
boolean isPGDumpAll = process.contains(REDIRECT);

if (isPGDumpAll)
{
int someNum = process.indexOf(REDIRECT);
fileName = process.substring(someNum + 1).trim();
process = process.substring(0, someNum);
}

// Executing the process
Process theProcess = run.exec(process.trim());

// New Thread Started to know Errors from Postgres Server


// Wait till process Leaves the Control
int exit = theProcess.waitFor();

     }

}


I tried to run this code in jre 1.6_ 35 patch it is working but it was not working in latest version 1.6_35 and 1.7 jdk
it is giving the following error

when i am running this Process theProcess = run.exec(process.trim());

create process error 2 this system cannot find the file specified.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points