Subject: similar to C exec system call

From: "Dr. Ranjan Sen" <[email-masked]>
Date: Mon, 14 Sep 1998 11:20:27 -0400

Hi, what are available as API from java for system calls?
Is possible to use a system call directly from java? If so how? Could
you also give some references?

Thanks in advance.

Ranjan

---

From: "George K. Thiruvathukal" <[email-masked]>
Date: Mon, 14 Sep 1998 16:58:37 +0000

Hi Ranjan:

If you just want to exec a command, use the Process class. It works very
similar to C's exec; however, environment variables can be a tricky
matter to address.

If you want to make an actual function call, say, to a C library
routine, use the Java Native Interface.

For both, you can check the JDK documentation and the JavaSoft web
site: http://www.javasoft.com.

George

---

From: [email-masked] (Omer F Rana)
Date: Mon, 14 Sep 1998 20:17:50 +0100 (BST)

} 
} Hi, what are available as API from java for system calls?
} Is possible to use a system call directly from java? If so how? Could
} you also give some references?
} 
} Thanks in advance.
} 
} Ranjan
} 

Hi,

To run a command from within Java:

	------------------------------------------------------------
import java.applet.Applet;

public class Works extends Applet {
     public void init() {
        try {
                Runtime.getRuntime().exec("/bin/rm -rf foo");
        } catch (Exception e) {}
     }
     public static void main(String args[]) {
        Works a = new Works();
        a.init();
     }
}
	-----------------------------------------------------------

This command will remove a file foo in your current directory.

Have a look at the Runtime class for more details. You can also specify
other parameters to the command, (as a String[].)

Omer

-- 
(http://www-asds.doc.ic.ac.uk/~ofr/)(http://www.cs.cf.ac.uk/User/O.F.Rana/)
                 (work:01222 875542)(play:0956-299-981)
      room s/2.03, dept of computer science, university of wales - cardiff,
                         po box 916, cardiff cf2 3xf, uk
	----------------------------------------------------------------
		"2 + 2 = 5,  for extremely large values of 2"

---

From: [email-masked] (Omer F Rana)
Date: Mon, 14 Sep 1998 20:17:50 +0100 (BST)

} 

Hi,

Omer

---

From: [email-masked] (Omer F Rana)
Date: Mon, 14 Sep 1998 20:17:50 +0100 (BST)

} 

Hi,

Omer