Advertisement Jump to content
Sign in to follow this  

[java] Image IO Permission

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

If you intended to correct an error in the post then please contact us.

Recommended Posts
Loading image: bullet.gif access denied ( bullet.gif read)
	at Source)
	at Source)
	at java.lang.SecurityManager.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 Fullscreen.loadImage(
	at Fullscreen.<init>(
	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.runLoader(Unknown Source)
	at Source)
	at 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) {
		System.out.println("Loading image: " + 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 this post

Link to post
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 this post

Link to post
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 "<<ALL FILES>>", "read,execute";


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!