简体   繁体   English

解决java.security.AccessControlException的快速方法

[英]A quick way to solve java.security.AccessControlException

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. 我试图将java.policy.applet文件放入授予读取权限的文件中,但是它不起作用。 I need a quick way to solve this problem. 我需要一种快速的方法来解决这个问题。 I have to specify that for making this applet I used java 6. 我必须指定使用Java 6来制作此applet。

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). 您说过要读取服务器上的文件,但是异常是由于尝试读取客户端(运行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. 您需要通过HTTP访问它们,或将它们放入applet的jar文件并从那里加载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM