Reputation: 3640
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?
Upvotes: 9
Views: 7698
Reputation: 100706
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.
Upvotes: 14