execute unix command using java

HelloCan we execute a unix command using java? If it is how we can execute. Is this affect the performance of the program.Thanks
[149 byte] By [Rosy_Thomas@Javaa] at [2007-11-27 7:10:18]
# 1
You might find class [url= http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Runtime.html]Runtime[/url] to be interesting.
thomas.behra at 2007-7-12 19:01:47 > top of Java-index,Java Essentials,Java Programming...
# 2

> Hello

>

> Can we execute a unix command using java?

Yes

>If it is

> how we can execute.

Runtime.getRuntime().exec("ls -a");

>Is this affect the performance of

> the program.

>

>

http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

>

> Thanks

You are welcome

Jamwaa at 2007-7-12 19:01:47 > top of Java-index,Java Essentials,Java Programming...
# 3

I tried what you said. But its not working and returning error message,

java.io.IOException: CreateProcess: ls -a error=2

at java.lang.ProcessImpl.create(Native Method)

at java.lang.ProcessImpl.<init>(Unknown Source)

at java.lang.ProcessImpl.start(Unknown Source)

at java.lang.ProcessBuilder.start(Unknown Source)

at java.lang.Runtime.exec(Unknown Source)

at java.lang.Runtime.exec(Unknown Source)

at java.lang.Runtime.exec(Unknown Source)

If i try this statement,

Runtime.getRuntime().exec("c\windows\notepad");

It is working fine.

Any idea about this.

Plz ...........

Rosy_Thomas@Javaa at 2007-7-12 19:01:47 > top of Java-index,Java Essentials,Java Programming...
# 4
It sounds like you're trying to execute a unix command in Windows. That this doesn't work has nothing to do with Java.And no, this did not work: Runtime.getRuntime().exec("c\windows\notepad");
jverda at 2007-7-12 19:01:47 > top of Java-index,Java Essentials,Java Programming...
# 5
I tried this in linux and it is working fine.Thanks a lot
Rosy_Thomas@Javaa at 2007-7-12 19:01:47 > top of Java-index,Java Essentials,Java Programming...
# 6
> I tried this in linux and it is working fine.Fantastic.
cotton.ma at 2007-7-12 19:01:47 > top of Java-index,Java Essentials,Java Programming...