Example usage for java.lang SecurityManager checkExit

List of usage examples for java.lang SecurityManager checkExit

Introduction

In this page you can find the example usage for java.lang SecurityManager checkExit.

Prototype

public void checkExit(int status) 

Source Link

Document

Throws a SecurityException if the calling thread is not allowed to cause the Java Virtual Machine to halt with the specified status code.

Usage

From source file:Main.java

public static void main(String[] args) {
    System.setProperty("java.security.policy", "file:/C:/java.policy");

    SecurityManager sm = new Main();

    System.setSecurityManager(sm);

    // perform the check
    sm.checkExit(5);
    System.out.println("Allowed!");
}