• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Applet error NoClassDefFoundError when run through HTML file

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have created compiled and run many Java programs, but this is my first applet. I am doing a project for school basically to connect a DB to a java applet. I have the class set up and when I run through Netbeans "Run File" It works perfectly. I am able to connect to the DB... no issues at all. So now I just need it to work through an HTML window... This is where my issue starts. I have tried to read as much about applets as I can but still do not understand a lot of what I read.

When I run the applet through an HTML window I get the error: java.lang.NoClassDefFoundError: org/jdesktop/layout/GroupLayout$Group

The .html file I am using is the one in the project/build folder under the default netbeans project structure.



I have confirmed that the following path is correct. (<APPLET codebase="classes" code="DBapp/appletgui.class")

Also, I am using swing-layout-1.0.4.jar I think this might be part of my problem.
 
Saloon Keeper
Posts: 7585
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, you need an archive attribute that points to the jar file. If you keep the jar file in the same directory as the HTML file, then it would just read archive="swing-layout-1.0.4.jar".
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, your problem is that you are using resources found in JARs which are not available to the applet runtime. You have to move these JARs into someplace reachable by clients (i.e. someplace your web server can share them from), preferably relative to the applet's codebase attribute. Then you add an archive attribute to the applet tag with the path to the JAR. So for example, your codebase is classes, so you might have:
classes/
classes/DBApp/ (your appletgui.class here)
classes/lib/ (your .JAR files here)


Then your applet tag might look like:
 
Brennen smith
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you I knew it had something to do with that .jar. Everything is working perfectly now.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic