This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Java Runtime.exec()


If that's literally the code you're executing, the most obvious problem is 
the argument to rt.exec(...). If those quotation marks are in there, get 
rid of them, turning a string literal into a variable reference, which is 
certainly what you intended.

And you'll be on to your next problem. I think you'd be better of not 
assuming anything about the working directory of a Java program, since it's 
not a defined aspect of the Java Runtime Environment. It would probably be 
better to set the PATH environment (also not specified, but it will work on 
any system where Runtime.exec(...) will work) to include the directory 
(-ies) that contain commands you need to execute.

Lastly, keep in mind that there is no Cygwin-enabled JVM, so CLASSPATH and 
file name and command syntax, etc. will have to be Windows native, not 
Cygwin style.

Randall Schulz

At 18:03 2001-07-09, SAWANT,SACHIN (Non-HP-PaloAlto,ex1) wrote:
>We are using cygwin to run our application. I am trying to execute a shell
>file at the operation system through java. The code is as follows
>      String unixCommand = "./";
>      Runtime rt = Runtime.getRuntime();
>      Process proc = rt.exec("unixCommand");
>      InputStream result = proc.getInputStream();
>      InputStreamReader isr = new InputStreamReader(result);
>      BufferedReader br = new BufferedReader(isr);
>      String line = null;
>      while ( (line = br.readLine()) != null)
>              out.println(line);
>      int exitVal = proc.waitFor();
>   I am getting CreateProcess Exception when I try to run this code. It does
>work well for other unix commands like "ls" or "ps". Am I doing something

Unsubscribe info:
Bug reporting:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]