PDA

View Full Version : Applet error - Access Control Exception: access denied



dan0
02-17-2009, 03:54 PM
I've put together an applet that is supposed to display a user's file system via a JTree. Unfortunately, I've been getting an access control exception error. Does anyone know how to overcome the following error?


Java Plug-in 1.6.0_11
Using JRE version 1.6.0_11 Java HotSpot(TM) Client VM

java.security.AccessControlException: access denied (java.util.PropertyPermission * read,write)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPropertiesAccess(Unknown Source)
at java.lang.System.getProperties(Unknown Source)
at TreeApplet.<init>(TreeApplet.java:17)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception: java.security.AccessControlException: access denied (java.util.PropertyPermission * read,write)


Here is my code:

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.JTree.*;
import java.util.*;


/*
<applet code="TreeApplet.class" width=300 height=100>
</applet>
*/

public class TreeApplet extends Applet {
// Create default tree
Properties systemProperties = new Properties(System.getProperties());
JTree systemTree = new JTree(systemProperties);
JScrollPane scrollPane = new JScrollPane(systemTree);
JPanel panel = new JPanel(new FlowLayout());

public void init(){
systemTree.setRootVisible(true);
panel.add(scrollPane);
setLayout(new FlowLayout());
add(panel);
setVisible(true);
}

public void start(){

showStatus("Java Tree");
}


}

JVposter
02-20-2009, 02:33 PM
Hello!

http://www.wutka.com/hackingjava/ch3.htm
You can not to have access to file system from an applet. It is a security measure.

http://www.captain.at/programming/java/