gpt4 book ai didi

Java在Java程序中运行Main方法之后不退出

转载 作者:太空宇宙 更新时间:2023-11-04 09:38:09 34 4
gpt4 key购买 nike

嗨,我使用以下代码 to run main method with args from another jar :

import com.foo.bar.MainApp;

class MyInitClass {
public static void main(String args[]) {

// call second main method
MainApp.main(new String[] {"-port", "8080"});

// this code gets never executed
System.out.println("Never gets called");
}
}

嵌套的 main(new String[] {"-port", "8080"}) 方法被执行,但随后整个程序正常退出。

我怎样才能继续执行System.out.println

最佳答案

问题是.jar文件中的main方法调用“System.exit()”,所以我必须更改jar文件的源代码。感谢您指出这一点。

enter image description here

关于Java在Java程序中运行Main方法之后不退出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56252932/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com