0

Hi I use the following code 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");
    }
}

The nested main(new String[] {"-port", "8080"}) method gets executed but then the whole program gracefully exits.

How can I continue that the System.out.println gets also executed.

Viktor Carlson
  • 989
  • 1
  • 13
  • 36

1 Answers1

0

The problem is that the main method in the .jar file calles "System.exit()" so I have to change the source code of the jar file. Thanks for pointing that out.

enter image description here

Viktor Carlson
  • 989
  • 1
  • 13
  • 36