Hello All,

I have written a simple program to execute "ls" through java. But it
isnt working. Can any one point out the error?

class ExecDemo{
public static void main(String args[]){
        Runtime r=Runtime.getRuntime();
        Process p=null;
        String cmd{}={"ls"};
        try{
        p=r.exec(cmd);
        }catch(Exception e){
        System.out.println(error+cmd[0]);
        }
        }
}

When I run it, the program does not do "ls" and silently quits. When I
changed "ls" with "vi ExecDemo.java" it said error vi ExecDemo.java.
In the book in which this program is given the command for String cmd[]
is as:
String cmd[]={"ls","/java/src/java/lang/Runtime.java"};

But, I am not able to locate Runtime.java anywhere on my machine..
Please point out the correct procedure to run the above code.

Thanks
Alpesh


===
KOTHARI ALPESH D.
STUDENT M. TECH.
CEDT
INDIAN INSTITUTE OF SCIENCE
BANGALORE-560 012
INDIA
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to