import java.security.AccessControlException; import java.security.Guard; import java.security.GuardedObject; import java.util.PropertyPermission; public class Main { public static void main(String[] argv) throws Exception { String secretObj = "secret"; Guard guard = new PropertyPermission("java.home", "read"); GuardedObject gobj = new GuardedObject(secretObj, guard); try { Object o = gobj.getObject(); } catch (AccessControlException e) { e.printStackTrace(); } } }