f



execute java app from within java

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
0
10/25/2006 10:46:09 AM
comp.lang.java.help 13339 articles. 0 followers. Post Follow

1 Replies
729 Views

Similar Articles

[PageSpeed] 43

Petterson Mikael schrieb:
> 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");

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
0
10/25/2006 1:03:57 PM
Reply: