Given the class below,
public class ClassOne {
public static void main(String... args) {
System.exit(1);
}
}
The following class will be destroyed as well, assuming there are other things to do after ClassOne.main is invoked.
public class ClassTwo {
public static void main(String... args) {
ClassOne.main(args);
Thread.sleep(30000);
}
}
Is there a way to ignore the System.exit(1); of ClassOne in ClassTwo's invocation?
You can't ignore it per se, but you can prevent it from terminating the JVM via SecurityManager. Take a look at this question for detailed code example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With