Jump to content
  • Advertisement
Sign in to follow this  
Jebediah

[java] Image IO Permission

This topic is 4808 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

http://www.evilkarma.com/zombie/
Loading image: bullet.gif
java.security.AccessControlException: access denied (java.io.FilePermission bullet.gif read)
	at java.security.AccessControlContext.checkPermission(Unknown Source)
	at java.security.AccessController.checkPermission(Unknown 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(Fullscreen.java:273)
	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.runLoader(Unknown Source)
	at sun.applet.AppletPanel.run(Unknown Source)
	at java.lang.Thread.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) {
		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
Advertisement
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 java.io.FilePermission "<<ALL FILES>>", "read,execute";
};


cheers

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!