...

View Full Version : running a programme from another in Java



kuskyboy
04-07-2005, 03: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?

Kusky

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

classname.main();
such as the class you are running is bob it would be
bob.main();
but bob must be in the same folder you have the first one in

JWizard
04-08-2005, 03: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.

kuskyboy
04-11-2005, 03: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

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum