0

how to prevent from executing System.exit(). If in middle of code exit() method is called. JVM should throw compile time exception

developer
  • 9,309
  • 29
  • 85
  • 144

1 Answers1

2

does this thread help?

Otherwise/In short, you could implement your own Security Manager like this:

class MySecurityManager extends SecurityManager {
  @Override public void checkExit(int status) {
    throw new SecurityException();
  }
}
Community
  • 1
  • 1
Winfred
  • 875
  • 6
  • 12