tags:

views:

24

answers:

2

I mean someting conceptually similar to Runtime.getRuntime().exec(...) but which allows to invoke directly the class without calling exec("java -classpath $currentClasspath my.class.name")...

Just to notice that tools.jar has an useful java class for compiling specifically java sources, there is something similar for executing directly java classes?

A: 
String[] args = {"foo", "bar"};
my.pkg.MyClass.main(args);

Of course, you have to make sure that my.pkg.MyClass is on your classpath at compile time and build time.

Mike Baranczak
Not so easy, I need to isolate the OpenGL thread otherwise inherited
Steel Plume
A: 

If you have a JAR and you know the API, you can call new on any class and run them as if they were your own. I am not sure what you are asking here. Of course main is just another method of a class, albeit a static one.
Calling exec starts the program in another process, which gives you certain benefits. You might be able to call main in another Thread if desired.
Maybe a little more detail would be good.

Romain Hippeau
I need to isolate the OpenGL thread otherwise inherited by the invoker class, creating a new one for the invoked class in another JVM process
Steel Plume