Runtime.exec() Problem.

Patrick W. O'Neill oneill at
Sun Sep 6 07:33:50 PDT 1998

Hello, I'm relatitivly new to Java, and even moreso to Kaffe.  We have a 
demonstration that runs only on Linux.  This demo generates a logfile, 
which is read by our java program to display graphically what is going 
on.  Previously, we would generate the logfile on a Linux machine, and 
run the Java demo on Solaris with the JDK.  We would like to be able to 
generate the logfile on the fly, so our only option is to run the Java 
demo on the linux machine.  That is where Kaffe comes in.  

We had to do a lot of updating of our code, the books we had were 1.0 
books, and JDK is more forgiving of deprecated functions than Kaffe is, 
so we had no need to use 1.1 code until we decided to use Kaffe.  We got 
that all straightend out, but we're having one main problem.  We need to 
run our program from inside our java demo, this would lead me to using a 
Runtime.exec("command line") call.  This works fine under JDK, but I'm 
having a problem running this with Kaffe.  Here is some sample code...

public class Test{
  public static void main(String[] args) {
    Runtime r = Runtime.getRuntime();
    System.out.println("Hello World!");
    try {
      r.exec("gcc test.c");
    catch( e) {

No matter what the command is, we get No such file or directory 

I just tried an example using full path names, we don't get the 
exception, but the command just plain doesn't get executed.

I also tried some code I found in the newsgroup...

public class HelloWorld{
  public static void main(String[] args) {
    try {
      String cmd = "/usr/bin/ls -l /opt/java/bin";
      String line = null;
      Process p = Runtime.getRuntime().exec(cmd);
      BufferedReader lsOut = new BufferedReader
       (new InputStreamReader
          (p.getInputStream() ) );
      while( ( line=lsOut.readLine() ) != null) {
    catch (Exception e) {
        System.err.println("ls error " +e);

But I get the same error.  Any ideas as to why this might be happening or 
how to fix it?  Thanks.


More information about the kaffe mailing list