Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.File;
import java.net.URL;
import java.security.CodeSource;
import java.security.Permission;
import java.security.PermissionCollection;
import java.security.Policy;
import java.security.cert.Certificate;
import java.util.Enumeration;

public class Main {
    public static void main(String[] argv) throws Exception {

        SecurityManager sm = new SecurityManager();
        System.setSecurityManager(sm);
        URL codebase = new URL("http://java.sun.com/");

        //codebase = new File("c:\\java\\").toURI().toURL();
        //codebase = new File(System.getProperty("user.home")).toURI().toURL();

        CodeSource cs = new CodeSource(codebase, (Certificate[]) null);

        PermissionCollection pcoll = Policy.getPolicy().getPermissions(cs);

        Enumeration e = pcoll.elements();
        for (; e.hasMoreElements();) {
            Permission p = (Permission) e.nextElement();
        }
    }
}