System call in Java

Can we make calls to programs written in other languages using java. Is it possible that we can call Unix OS commands and Utilities using Java.
[157 byte] By [rmahale] at [2007-9-26 1:30:48]
# 1
Yes; with JNI and Runtime.exec(). Readign this article may prove useful: http://www.javaworld.com/jw-12-2000/jw-1229-traps.html
jsalonen at 2007-6-29 1:29:25 > top of Java-index,Archived Forums,Java Programming...
# 2

you can do that with

Process p = Runtime.getRuntime().exec(command);

there are many overloaded exec methods. see the api docs here.

http://java.sun.com/j2se/1.3/docs/api/java/lang/Runtime.html

but before you do that read this article for problems with exec and how to avoid them

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

hth

partha

parthasarkar at 2007-6-29 1:29:25 > top of Java-index,Archived Forums,Java Programming...