如何从动作中运行其他java程序/类?

时间:2021-03-23 20:48:43

Hi I'd like to knew how I can run / start another class(from the same package) in my program. I want it to run independent but at the same time I'd like it to be packed in my jar.

嗨,我想知道如何在我的程序中运行/启动另一个类(来自同一个包)。我希望它独立运行,但同时我希望它能装在我的罐子里。

1 个解决方案

#1


2  

Thread API:

http://docs.oracle.com/javase/6/docs/api/java/lang/Thread.html

Possible solution:

Thread thread = new Thread(new Runnable() {
    public void run() {
        SomeClass.main(new String[]{});
    }
});
thread.start();

#1


2  

Thread API:

http://docs.oracle.com/javase/6/docs/api/java/lang/Thread.html

Possible solution:

Thread thread = new Thread(new Runnable() {
    public void run() {
        SomeClass.main(new String[]{});
    }
});
thread.start();