# [java] Image IO Permission

This topic is 4726 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

http://www.evilkarma.com/zombie/
Loading image: bullet.gif
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(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 Fullscreen.<init>(Fullscreen.java:53)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)

I get this whenever I run my program through a browser. Applet viewer works fine. This problem seemed random at first (I just kept redoing everything until it worked) but now it never works. Here is the troublesome code:
	public Image loadImage(String filename) {
//if (applet) return new ImageIcon(getImage(getCodeBase(), filename)).getImage();
if (applet) return getImage(getCodeBase(), filename);
else return new ImageIcon(filename).getImage();
}

The commented out line is the code I used in the past and it worked fine. I tried both (and more) but with no avail. Any help would be appreciated. It should work because it is in the subdirectory of the main program. I even tried the same folder with no avail. Does it work for anybody else?

##### Share on other sites
At the risk of sounding stupid, did you checked the permissions of the file in question (bullet.gif), aka chmod'ed it by means of an ftp client or a shell?
You need to give read permissions to everyone, for example, with
\$ chmod 733
or just via a graphic interface like the one in the ftp client, or the web based interface that your host provides you with

BTW, I also got that problem, and by looking just at the description and the trace, seems like a problem with file permissions

cheers, and sorry if I sounded too childish

##### Share on other sites
I even tried 777. That was the first thing I tried actually =)

##### Share on other sites
Try this (beforehand Ill tell you Ive never work with Java permissions, just read about them)

Create a file named ".java.policy" in the folder where you image is

Now, put the following inside that file

grant codeBase "file:bullet.gif" {  permission java.io.FilePermission "<<ALL FILES>>", "read,execute";};

cheers

• 9
• 13
• 41
• 15
• 13