PDA

View Full Version : ClassNotFoundException Error


Dan06
03-02-2009, 10:48 PM
When I try to run my applet in a Firefox or IE browser I get the error below, anyone know how to resolve this?


load: class TestAppletGUI not found.
java.lang.ClassNotFoundException: TestAppletGUI
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(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.io.IOException: open HTTP connection failed: server_address/TestAppletGUI.class
at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 7 more
Exception: java.lang.ClassNotFoundException: TestAppletGUI


There are two classes TestAppletGUI and AppletGUI, which are in a named package - projects.web - both of these classes are archived in UserInterface.jar

In my web-page I use an applet tag:

<applet code="TestAppletGUI" archive="UserInterface.jar" width="500" height="500">
</applet>

brad211987
03-03-2009, 04:52 PM
I think you need to give the fully qualified name in your code attribute.

Try something like:
code="projects.web.TestAppletGUI"

Dan06
03-05-2009, 05:48 PM
Thanks for the suggestion.

I got the applet to run by:

1. Changing the code reference to: projects.web.TestAppletGUI (the FQCN)
2. Re-archiving the class files (with their proper directory relations intact)


To create the jar file I used the following cmd:
jar cvf UserInterface.jar projects\web\AppletGUI.class projects\web\TestAppletGUI.class