I have a problem with my images in my java project. The project is a simple chess program for human players only. The problem is that it works fine in JCreator Lite's Apllet viewer but when I try to open it in an HTML it gives me the error mentioned in the thread title. As I'm really a newbie in java any help would be greatly appreciated. Here's the code I think makes the trouble in browsers:

private Image FeherParasztImage = getToolkit().createImage("feher_paraszt.gif");
	private Image FeketeParasztImage =   getToolkit().createImage("fekete_paraszt.gif");
	private Image FeherBastyaImage = getToolkit().createImage("feher_bastya.gif");
	private Image FeketeBastyaImage = getToolkit().createImage("fekete_bastya.gif");
	private Image FeherLoImage = getToolkit().createImage("feher_lo.gif");
	private Image FeketeLoImage = getToolkit().createImage("fekete_lo.gif");
	private Image FeherFutoImage = getToolkit().createImage("feher_futo.gif");
	private Image FeketeFutoImage = getToolkit().createImage("fekete_futo.gif");
	private Image FeherKiralynoImage = getToolkit().createImage("feher_kiralyno.gif");
	private Image FeketeKiralynoImage = getToolkit().createImage("fekete_kiralyno.gif");
	private Image FeherKiralyImage = getToolkit().createImage("feher_kiraly.gif");
	private Image FeketeKiralyImage = getToolkit().createImage("fekete_kiraly.gif");
	private Image AtlatszoImage = getToolkit().createImage("atlatszo.gif");
	private Image mutatoImage = getToolkit().createImage("mutato1.gif");

	//letrehozom a babuk ikonjait a kepekbol
	ImageIcon FeherParasztIcon = new ImageIcon(FeherParasztImage);
	ImageIcon FeketeParasztIcon = new ImageIcon(FeketeParasztImage);
	ImageIcon FeherBastyaIcon = new ImageIcon(FeherBastyaImage);
	ImageIcon FeketeBastyaIcon = new ImageIcon(FeketeBastyaImage);
	ImageIcon FeherLoIcon = new ImageIcon(FeherLoImage);
	ImageIcon FeketeLoIcon = new ImageIcon(FeketeLoImage);
	ImageIcon FeherFutoIcon = new ImageIcon(FeherFutoImage);
	ImageIcon FeketeFutoIcon = new ImageIcon(FeketeFutoImage);
	ImageIcon FeherKiralynoIcon = new ImageIcon(FeherKiralynoImage);
	ImageIcon FeketeKiralynoIcon = new ImageIcon(FeketeKiralynoImage);
	ImageIcon FeherKiralyIcon = new ImageIcon(FeherKiralyImage);
	ImageIcon FeketeKiralyIcon = new ImageIcon(FeketeKiralyImage);
	ImageIcon AtlatszoIcon = new ImageIcon(AtlatszoImage);
	ImageIcon mutatoIcon = new ImageIcon(mutatoImage);

p.s.: all the gif's exist and are in the same folder as the Html.. I'm really lost with that one if anyone has any idea please help

Recommended Answers

All 4 Replies

Can you post the full text of the error message? And the lines in your program referred to in the error message.

Can you post the full text of the error message? And the lines in your program referred to in the error message.

the error message goes like this:

java.lang.reflect.InvocationTargetException
at com.sun.deploy.util.DeployAWTUtil.invokeAndWait(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.runOnEDT(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.security.AccessControlException: access denied (java.io.FilePermission feher_paraszt.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.createImage(Unknown Source)
at Sakk1.<init>(Sakk1.java:113)
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.plugin2.applet.Plugin2Manager$12.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(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)
Exception: java.lang.reflect.InvocationTargetException
java.lang.reflect.InvocationTargetException
at com.sun.deploy.util.DeployAWTUtil.invokeAndWait(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.runOnEDT(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.security.AccessControlException: access denied (java.io.FilePermission feher_paraszt.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.createImage(Unknown Source)
at Sakk1.<init>(Sakk1.java:113)
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.plugin2.applet.Plugin2Manager$12.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(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)
Exception: java.lang.reflect.InvocationTargetException
java.lang.reflect.InvocationTargetException
at com.sun.deploy.util.DeployAWTUtil.invokeAndWait(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.runOnEDT(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.security.AccessControlException: access denied (java.io.FilePermission feher_paraszt.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.createImage(Unknown Source)
at Sakk1.<init>(Sakk1.java:113)
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.plugin2.applet.Plugin2Manager$12.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(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)
Exception: java.lang.reflect.InvocationTargetException

the part of the code it keeps referring to is line 113 which is the first line of the code I posted previously:

private Image FeherParasztImage = getToolkit().createImage("feher_paraszt.gif");

So I guess it would do the same thing for all the images

Caused by: java.security.AccessControlException: access denied (java.io.FilePermission feher_paraszt.gif read)

This line says that you code does NOT have permissio to read the file.
How are you executing the applet?
Are the html, class and gif files all in the same folder?
Are you using a server or are you opening the html file in the local folder directly?
What OS and version of java are you using?

When running the program from outside of appletviewer, don't forget to do the whole jarsigning procedure!

Here is what you you do:

1 Go to Start, then run, then type in cmd
2 type in:

path=C:\Program Files\Java\jdk1.6.0_20\bin

or where ever your java binary directory is,
3. type in

keytool -genkey -keyalg rsa -alias yourkey

then follow the instructions
4. jar your files by going to your classes directory and typing in:

jar cvf yourapplet.jar yourapplet.class

AFTER everything has been compiled

yourapplet.jar is whatever you want to call the .jar
yourkey is the key to use
5. jarsign your files by doing this:

jarsigner yourapplet.jar yourkey

6. open your html file and put this in:

<applet code="yourapplet.class" archive="yourapplet.jar" width="600" height="500">
</applet>

You can change the height and width variables

Hope that helps!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.