سؤال

I am working in an applet. It works perfect with Eclipse but when I try to run from Console it gives me this stack trace:

C:\Course Technology\src>appletviewer TestJAlienHunt.html

Path for file entered D:\Course Technology\AssignmentFinal\scoreFile.txt java.security.AccessControlException: access denied ("java.io.FilePermission" "D:\Course Technology\AssignmentFinal\scoreFile.txt" "read")
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:366)
    at java.security.AccessController.checkPermission(AccessController.java:555)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
    at java.lang.SecurityManager.checkRead(SecurityManager.java:888)
    at sun.nio.fs.WindowsPath.checkRead(WindowsPath.java:792)
    at sun.nio.fs.WindowsFileSystemProvider.checkAccess(WindowsFileSystemProvider.java:360)
    at java.nio.file.Files.exists(Files.java:2311)
    at ReadFile.fileExists(ReadFile.java:47)
    at JAlienHunt.readScore(JAlienHunt.java:187)
    at JAlienHunt.init(JAlienHunt.java:73)
    at sun.applet.AppletPanel.run(AppletPanel.java:434)
    at java.lang.Thread.run(Thread.java:722)

The file has permission to read and write, why I am getting this?

هل كانت مفيدة؟

المحلول

An applet needs to be digitally signed by you and trusted by the end user before it can access the local file system on the user's computer.

I highlight user's computer because that is where any File will equate to. There is no option for getting a File pointing to the server. If this is read only and the server hosts the resource, access it by URL.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top