Example usage for java.lang SecurityManager checkPackageAccess

List of usage examples for java.lang SecurityManager checkPackageAccess

Introduction

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

Prototype

public void checkPackageAccess(String pkg) 

Source Link

Document

Throws a SecurityException if the calling thread is not allowed to access the specified package.

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);

    sm.checkPackageAccess("java2s.com");

    System.out.println("Allowed!");
}