When I try to run an applet for my game, I get an error that looks like this.
I clicked on it, and got a message that looked like this.
How do I know what’s wrong?
When I try to run an applet for my game, I get an error that looks like this.
I clicked on it, and got a message that looked like this.
How do I know what’s wrong?
Well, you’re looking in the right place. I assume your code works locally? Can you load the HTML locally and run the applet? Double check the applet tag settings in the HTML page. Does the code attribute (in the tag) have the full package path?
It just looks like the class isn’t found.
Can’t really tell anything else without seeing the code, can you link a page with the applet?
Thanks for your reply. Heres my source code.
Build http://www.mediafire.com/?bas4apehvz1aoo7
src http://www.mediafire.com/?toc0k3j2mnmi1gb
I’ve found the reason, but I can’t seem to get why. Its because I had a package called ultrapong, that had all my source codes and other packages in it.
But if I didn’t have them all in the package ultrapong and had them in the netbeans default package,some classes won’t be able to extend another class.
You would need to include the classes from your other package or us the FQN. This link should clear all that stuff up for you. http://download.oracle.com/javase/tutorial/java/package/packages.html
I was wondering if your html applet tag had something like this in it
code="ultrapong.Applet.GameApplet"
Originally, my code looked like this
code = "UltraPong.class"
So I tried
code = "ultrapong.UltraPong.class"
But after the link you gave me(Thanks, that was really helpful ;D)
my code looks like this
code ="ultrapong"
Since all my codes and packages are under ultrapong.
But for some reason, it sill didn’t work. Did I miss or misunderstand something?
code = "ultrapong.UltraPong"
Thanks for the quick reply.
But for some reason, even the
code = "ultrapong.UltraPong"
Didn’t work.
Go into the build directory that you posted in the build zip file, above. There is a file “UltraPong.html”. Load that in your favorite bowser. I ran it this way and got this stack trace. After you fix the NoClassDefFoundError, use that html and add a classes directory for your source code, or make a jar file and change the HTML line (codebase=“classes”) to (archive=“Jarname.jar”).
java.lang.RuntimeException: java.lang.NoClassDefFoundError: mylibrary/Graphics/Button
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.lang.NoClassDefFoundError: mylibrary/Graphics/Button
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at ultrapong.startscreen.Menu.<init>(Menu.java:27)
at ultrapong.UltraPong.<init>(UltraPong.java:30)
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.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(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)
Caused by: java.lang.ClassNotFoundException: mylibrary.Graphics.Button
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 32 more
Exception: java.lang.RuntimeException: java.lang.NoClassDefFoundError: mylibrary/Graphics/Button
Thanks for the really helpful answer!
It works now ;D
If you don’t mind, could you tell me how to stack trace an applet.
You were looking in the right place. It will show up in the console.
I suspect your applet tag was not set correctly. If you use the file structure from the build directory and the HTML in there, you should be able to get it working.
Thanks ;D