11 Replies - 10688 Views - Last Post: 04 January 2012 - 04:28 AM Rate Topic: -----

#1 taskforce141   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 61
  • Joined: 04-July 11

"NoClassDefFound" error Applet

Posted 29 December 2011 - 02:10 PM

I made a video game applet in Java and I am now in the process of putting it on a web page. It can work as a simple html document using the jar file on anyone's computer, but when embedding it into a web page, I get the following error.

java.lang.RuntimeException: java.lang.NoClassDefFoundError: Level1
	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: Level1
	at java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
	at java.lang.Class.getConstructor0(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: Level1
	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)
	... 20 more
Exception: java.lang.RuntimeException: java.lang.NoClassDefFoundError: Level1



The code I am using for the html document follows...
<applet archive="testing.jar" width=1200 height=700 code="planeGame.class" />



Does anyone have an ideas as to why I am getting this error or how to fix? Thanks in advance to anyone who responds.

This post has been edited by taskforce141: 29 December 2011 - 02:10 PM


Is This A Good Question/Topic? 0
  • +

Replies To: "NoClassDefFound" error Applet

#2 g00se   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3744
  • View blog
  • Posts: 17,121
  • Joined: 20-September 08

Re: "NoClassDefFound" error Applet

Posted 29 December 2011 - 05:00 PM

Make sure you've packaged the class 'Level1' inside testing.jar
Was This Post Helpful? 0
  • +
  • -

#3 taskforce141   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 61
  • Joined: 04-July 11

Re: "NoClassDefFound" error Applet

Posted 29 December 2011 - 09:42 PM

That is something I haven't had too much practice with. Can you explain how would I do what you recommended?
Was This Post Helpful? 0
  • +
  • -

#4 g00se   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3744
  • View blog
  • Posts: 17,121
  • Joined: 20-September 08

Re: "NoClassDefFound" error Applet

Posted 30 December 2011 - 06:11 AM

Are you using Windows? If so, first check if the class is there by listing the jar at the command line:


jar tf testing.jar | find "Level1"

Was This Post Helpful? 0
  • +
  • -

#5 taskforce141   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 61
  • Joined: 04-July 11

Re: "NoClassDefFound" error Applet

Posted 31 December 2011 - 02:16 AM

I typed in this command, but I got a response saying
"'Jar' is not recognized as an internal or external command, operable program or batch file.
Was This Post Helpful? 0
  • +
  • -

#6 mi14chal   User is offline

  • D.I.C Head

Reputation: 82
  • View blog
  • Posts: 202
  • Joined: 11-December 10

Re: "NoClassDefFound" error Applet

Posted 31 December 2011 - 02:22 AM

Did you add path with jdk to system path?
Was This Post Helpful? 0
  • +
  • -

#7 g00se   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3744
  • View blog
  • Posts: 17,121
  • Joined: 20-September 08

Re: "NoClassDefFound" error Applet

Posted 31 December 2011 - 04:40 AM

You need a JDK installed and as has been mentioned, its bin directory needs to be on PATH. See Windows Help on 'Environment Variable'
Was This Post Helpful? 0
  • +
  • -

#8 Ghlavac   User is offline

  • D.I.C Addict

Reputation: 84
  • View blog
  • Posts: 519
  • Joined: 14-January 09

Re: "NoClassDefFound" error Applet

Posted 31 December 2011 - 04:55 AM

View Posttaskforce141, on 29 December 2011 - 09:42 PM, said:

That is something I haven't had too much practice with. Can you explain how would I do what you recommended?


Depends what IDE you use, most of them have an 'export' as jar function or something of the likes that usually automatically does this stuff for you.
Was This Post Helpful? 0
  • +
  • -

#9 g00se   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3744
  • View blog
  • Posts: 17,121
  • Joined: 20-September 08

Re: "NoClassDefFound" error Applet

Posted 31 December 2011 - 05:15 AM

If it's a question of having missed just the odd class, the following approach will work (assuming no package)


jar uvf testing.jar Level1.class

Was This Post Helpful? 0
  • +
  • -

#10 taskforce141   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 61
  • Joined: 04-July 11

Re: "NoClassDefFound" error Applet

Posted 03 January 2012 - 07:30 PM

Sorry I haven't responded in a couple of days, but after downloading software that allows me to open and see the contents of the jar file, I can see that "Level1" is in there. Now, how would I package this though as mentioned before?
Was This Post Helpful? 0
  • +
  • -

#11 taskforce141   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 61
  • Joined: 04-July 11

Re: "NoClassDefFound" error Applet

Posted 03 January 2012 - 08:40 PM

I was researching on this error for a while and I am thinking it might have to do with the fact that I also have a class called Level1$1.class in the jar. Could this be correct?
Was This Post Helpful? 0
  • +
  • -

#12 g00se   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3744
  • View blog
  • Posts: 17,121
  • Joined: 20-September 08

Re: "NoClassDefFound" error Applet

Posted 04 January 2012 - 04:28 AM

Please post the jar listing
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1