如何使用另一个罐子中的args运行main方法? [英] How to run main method with args from another jar?

查看:66
本文介绍了如何使用另一个罐子中的args运行main方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想启动一个我必须使用的* .jar中包含的main(String args [])方法(不要问,我已经受够了).

I'd like to start a main(String args[]) method that is contained in a *.jar I have to use (don't ask, I'm already fed up).

//this is my own class
class MyInitClass {
    public static void main(String args[]) {
          SomeJar.MainApp("-port", 8080);
    }
}


//this is a keen developers class
class MainApp {
    public static void main(String args[]) {
         //makes use of the arguments, like starting a socket server
    }
}

从我自己的类(最好是在单独的线程中)调用此类主方法的最佳方法是什么?

What is the best way to call such a main method from my own class, preferably in a separate Thread?

推荐答案

new Thread(new Runnable() {
    public void run() {
        MainApp.main(new String[] { "-port", "8080" });
    }
}).start();

这篇关于如何使用另一个罐子中的args运行main方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆