控制台不让我的小程序因为文件而运行 [英] Console don't let my applet run because of a file
问题描述
我在一个小程序中工作.它与 Eclipse 完美配合,但是当我尝试从控制台运行时,它给了我这个堆栈跟踪:
C:\Course Technology\src>appletviewer TestJalienHunt.html输入的文件路径 D:\Course Technology\AssignmentFinal\scoreFile.txt java.security.AccessControlException: access denied ("java.io.FilePermission" "D:\Course Technology\AssignmentFinal\scoreFile.txt" "read")在 java.security.AccessControlContext.checkPermission(AccessControlContext.java:366)在 java.security.AccessController.checkPermission(AccessController.java:555)在 java.lang.SecurityManager.checkPermission(SecurityManager.java:549)在 java.lang.SecurityManager.checkRead(SecurityManager.java:888)在 sun.nio.fs.WindowsPath.checkRead(WindowsPath.java:792)在 sun.nio.fs.WindowsFileSystemProvider.checkAccess(WindowsFileSystemProvider.java:360)在 java.nio.file.Files.exists(Files.java:2311)在 ReadFile.fileExists(ReadFile.java:47)在 JAlienHunt.readScore(JalienHunt.java:187)在 JAlienHunt.init(JAlienHunt.java:73)在 sun.applet.AppletPanel.run(AppletPanel.java:434)在 java.lang.Thread.run(Thread.java:722)
文件有读写权限,为什么我得到这个?
小程序需要经过您的数字签名并得到最终用户的信任,然后才能访问用户计算机上的本地文件系统.
em>
我突出显示用户的计算机,因为这是任何File
等同的地方.没有让 File
指向服务器的选项.如果这是只读的并且服务器托管资源,请通过 URL
访问它.
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
.
这篇关于控制台不让我的小程序因为文件而运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!