Question

Welcome, I had problem with launching my applet in browser, after few trys I finnaly had run that, i heard music, but the screen was still white, so i run console and i saw that error:

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)

It was strange to me because the sound track was playing in background but applet had a problem with loading images. I have put that applet on server: http://skibba.strefa.pl/applet/applet.html If you want to check. I am getting same error as while i was trying to launch the applet in browser from hard drive on my PC.

And if i have no permission, so why the music is playing?

The applet runs in eclipse's Applet:Viewer well - no errors, only in browser is the problem.

Was it helpful?

Solution

It was strange to me because the sound track was playing in background but applet had a problem with loading images.

Presuming the image and clip are in the same directory, it suggests the music clip is being loaded by URL from the 'home' location (OK for a sand-boxed applet) while the image is being loaded by File (only possible in a trusted applet, and not suitable for resources we supply for an applet).

Organize to load the image by URL, and it should work.

OTHER TIPS

Is kind of explanatory from the errors the application does not have permission to read from a folder where the png is stored. Applets are by default denied from accessing the Local directory. You need to sign your applet or edit the policy.

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

i hope it helped.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top