views:

452

answers:

1

I have an applet which have to read a file from server. But I receive the following exception

java.security.AccessControlException: access denied (java.io.FilePermission \kb1.xml read)
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.checkRead(Unknown Source)
at java.io.File.isDirectory(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
...

I tried to put a java.policy.applet file with permission granted for reading but it doesn't work. I need a quick way to solve this problem. I have to specify that for making this applet I used java 6.

+1  A: 

You said you want to read a file on the server, but the exception is caused by trying to read a file on the client (the machine that is running the applet).

You cannot read files from the server directly. You need to access them via HTTP or put them into the applet's jar file and load it from there.

Thilo
I forgot to change the name of accessed files.
Ionel Bratianu