I'm having problems accessing an image. I'm trying to put a simple, static image on to a Jlabel, and on to a JPanel. Here's the code:
ImageIcon image = new ImageIcon("CPA29.jpg");
JLabel imageLabel = new JLabel(image);
imagePane.add(imageLabel);
...with imagePane being a JPanel used to hold the JLabel holding the image.
When trying to run this, I get:
Java Console said:
java.security.AccessControlException: access denied (java.io.FilePermission CPA29.jpg 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 tpstart.init(tpstart.java:63)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception: java.security.AccessControlException: access denied (java.io.FilePermission CPA29.jpg 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 tpstart.init(tpstart.java:63)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception: java.security.AccessControlException: access denied (java.io.FilePermission CPA29.jpg read)
I find this very odd; the image is in the same directory as the applet class (As you can see from my CreateImageIcon constructor call). I looked up the AccessControlException on the Sun Java website, and the first thing I saw was this:
Sun said:
(Quoted text links to reference)
...leading me to OMGWTF mode. It later goes on to explain that you can set an individual permission file in the user directory to allow certain permissions, but I'm hesitant to do this, as it's a bit much to do that for every user just for a simple applet, and according to the appendix, it should work anyways.
My only thought is that this work computer that I'm using has just been rebuilt by our IT support company and is used as a standalone machine, and I may not have admin permissions. But surely, that shouldn't be a problem? After all, non admins need to see applets too!
Anyone have any ideas of what I'm doing wrong?
Please and thank you, once again
~Fae
EDIT: Turns out I am a local admin. There's that theory out the window.
Edited by Fae, 23 August 2010 - 03:17 AM.


Sign In
Create Account


Back to top









