View Full Version : running a programme from another in Java

04-07-2005, 04:56 PM
Im having lots of problems it would seem but my latest one (and hopfully my last) is this,

I have my min programme running but i need to call and runn another program (which also has its own main method), but i cant seem to get it to work.

any ideas?


04-08-2005, 04:17 AM
if it is a class and in the same folder as the class you are doing try this

such as the class you are running is bob it would be
but bob must be in the same folder you have the first one in

04-08-2005, 04:54 PM
Read up on the Runtime object. You can get a reference to it using getRuntime(), and use this reference to run external programs by using Runtime.exec().
Think of this as being able to use a shell within a program.
For example:

Runtime r = Runtime.getRuntime();
Process p = r.exec("java yournewprogram");
//now you have a process running yournewprogram

There are a few other details you may want to work out, read up on it.

04-11-2005, 04:43 PM
i have tried to use the Runtime object but when i compile is says

Runtime() has private access in java.lang.Runtime

i have read up on Runtime but i really dont know whats wrong!

Please help

04-11-2005, 08:23 PM
Please post the code in which you are trying to get and use the aforementioned Runtime object.