Java tutorial
public class Main extends SecurityManager { // checkPackageAccess needs to be overriden @Override public void checkPackageAccess(String pkg) { throw new SecurityException(); } 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!"); } }