class B {
public static void main(String[] args) {
}
}
class A {
public static void main(String[] args) {
B.main(args);
}
}
In the above flow, my init method is A.main which in turn calls B.main.
Option 2. The mains are just static methods of each class, and only one JVM is running when making the call from A to B.main(args)
.
You can also make use of this in JUNIT tests to help check the command line launch behaves as expected, such as
@Test void coverage() {
A.main(new String[] { "a","b" }); // or B.main
// assertions here if there is some output state you could check
}