Corne
Corne

Reputation: 496

Exception in thread "AWT-EventQueue-2" java.lang.NoClassDefFoundError

I get the error above in my Eclipse signed web applet. I would appreciate any help..

It states that my class is not found:

Exception in thread "AWT-EventQueue-2" java.lang.NoClassDefFoundError: com/dermalog/common/exception/DermalogException

Although I have images as proof that it is included in the build:

Image1 Image2

How I added my jar files:

  1. Made a "lib" folder
  2. Copied the jar files into the "lib" folder
  3. clicked "Properties" on the project
  4. Went to build path, libraries
  5. Added the jar reference

Upvotes: 0

Views: 3931

Answers (1)

david a.
david a.

Reputation: 5291

Adding a jar to project Java Build Path in an Eclipse project in most cases only means to add it to classpath used for compilation. Items set on build path are also used to create classpath when running your application or applet from within Eclipse.

The build path however does not say anything about the classpath of your applet when it runs in a different context, e.g. on a webpage. There, one needs to make sure that classpath contains all jars needed to run the app.

There are two simple ways to do this:

  • Add a manifest file to your JAR and specify the classpath (required JARs) there. Then, when deploying / copying your JAR to the location where it is being invoked, copy the dependency JARs as well.
  • Include all classes from the JARs your applet depends on to your applet's JAR. Eclipse's Export function allows this.

EDIT: Ok, I checked your jar file and found this:

  • MANIFEST.MF had no classpath definition. It should contain a line like:

Class-path: dermalog.afis.drawing.compression.jar dermalog.afis.fingercode.jar dermalog.imaging.capturing.jar

  • The dependency jars should not be packaged in the dependant jar. Instead, they should be just placed in the same directory (or in a subdirectory - but then use that subdirectory in classpath as well).

The page I linked above explains that.

Upvotes: 1

Related Questions