tags:

views:

184

answers:

1

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?

+9  A: 

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.

ChssPly76
Thanks for referring to this cool stuff. +1
Adeel Ansari
Thanks man, that saved me a lot of time.
Joset