Java小程序的游戏还没有获准读取的图像(Java applet game has not gran

2019-10-18 13:39发布

欢迎您,我有问题,我的启动浏览器的小程序,很少改掉后我finnaly已经用完,我听到了音乐,但屏幕仍然是白色的,所以我运行控制台,我看到这个错误:

Exception in thread "AWT-EventQueue-2" java.security.AccessControlException: access denied ("java.io.FilePermission" "grass.png" "read")
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    at java.security.AccessController.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at sun.plugin2.applet.AWTAppletSecurityManager.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkRead(Unknown Source)
    at sun.awt.SunToolkit.getImageFromHash(Unknown Source)
    at sun.awt.SunToolkit.getImage(Unknown Source)
    at javax.swing.ImageIcon.<init>(Unknown Source)
    at javax.swing.ImageIcon.<init>(Unknown Source)
    at rpg.imgs.loadAndDraw(imgs.java:18)
    at rpg.main.paint(main.java:343)
    at rpg.main.update(main.java:334)
    at sun.awt.RepaintArea.updateComponent(Unknown Source)
    at sun.awt.RepaintArea.paint(Unknown Source)
    at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$200(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

很奇怪,我因为音轨在后台打不过小程序曾与加载图像的问题。 我已经把那个小程序在服务器上: http://skibba.strefa.pl/applet/applet.html如果您想检查。 我收到同样的错误当我试图从硬盘启动小程序在浏览器中我的电脑上。

如果我没有权限,所以为什么正在播放的音乐?

小程序在Eclipse的小程序运行:浏览器很好 - 没有错误,只是在浏览器的问题。

Answer 1:

很奇怪,我因为音轨在后台打不过小程序曾与加载图像的问题。

假设图像和短片是在同一目录下,它表明了音乐剪辑正在加载URL从“家”的位置(OK了沙箱的小程序),而图像是由装载File在受信任的(唯一可能小程序,不适合我们为这个小应用程序提供的资源)。

组织通过URL来加载图像,它应该工作。



Answer 2:

是种从错误中解释性的应用程序没有权限从哪里PNG保存在文件夹阅读。 小程序在默认情况下访问本地目录拒绝。 您需要登录您的applet或编辑的策略。

http://www.coderanch.com/how-to/java/HowCanAnAppletReadFilesOnTheLocalFileSystem

我希望它帮助。



文章来源: Java applet game has not granted permission to read images