Something like this, maybe?
new Thread(new Runnable() {
@Override
public void run() {
MyRunnableClass.main(new String[]{});
}
}).start();
A runnable class is a normal class with a static main method. We can call that method like any other method. If we do that in a Thread, then we'll have something similiar to what the JVM would do when starting an application.
Full version with reflection:
public static void start(final String classname, final String...params) throws Exception { // to keep it simple
final Class<?> clazz = Class.forName(classname);
final Method main = clazz.getMethod("main", String[].class);
new Thread(new Runnable() {
@Override
public void run() {
try {
main.invoke(null, new Object[]{params});
} catch(Exception e) {
throw new AssertionError(e);
}
}
}).start();
}
Use it like
start("com.example.myApp", "param1", "param2");
and it will execute the main method of that class in a new Thread.