execute java app from within java

execute java app from within java

Post by Petterson » Thu, 26 Oct 2006 19:46:09


Hi,

Is there another way of launching a java program, from within another
java program, than using:

Runtime r = Runtime.getRuntime();
Process p = r.exec("c:/javac/bin/java -classpath c:\\Michael Sample");

What I want to do is to check if I have infocenter ( part of Eclipse)
running if not then I need to fire up eclipse's infocenter using command
(this is from a shell script):

java -classpath
$ECLIPSE_HOME/plugins/org.eclipse.help.base_3.2.0.v20060601.jar
org.eclipse.help.standalone.Infocenter -command $1 -port
$INFOCENTER_PORT -eclipsehome $ECLIPSE_HOME -noexec -data $data -host
`hostname`

cheers,

//mikael
 
 
 

execute java app from within java

Post by Simo » Thu, 26 Oct 2006 22:03:57

Petterson Mikael schrieb:

If it's on the classpath, just call (maybe in a separate Thread?)

Sample.main(new String[0]);

If it is not, use your own class loader to load the class from "C:\Michael" and
then call main(), possibly using reflection.
Note that when both programs are running in the same JVM they may of course
interfere by accessing static methods and fields etc.

(Don't know about Eclipse, though, but that doesn't seem to be relevant here.)

Cheers,
Simon