控制台别让因为文件的小程序我跑 [英] Console don't let my applet run because of a file
问题描述
我在applet工作。它的工作原理完全与Eclipse但是当我尝试从控制台运行它给了我这个堆栈跟踪:
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屋!