File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Eclipse, jars, and noClassDefFoundError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Eclipse, jars, and noClassDefFoundError" Watch "Eclipse, jars, and noClassDefFoundError" New topic

Eclipse, jars, and noClassDefFoundError

Karl Beowulph
Ranch Hand

Joined: May 31, 2004
Posts: 130

I have a very simple program called HelloWorld. I can't seem to jar it up properly though.


Jar contents
HelloWorld.class helloWorld\ helloWorld\
log4j.jar lib\ meta-inf\

When I attempt to run the JAR I get the following:

The contents of HellowWorld is:

I'm not sure if this would have any effect, but my java version is not the same as what I'm using to build the project.

I'm using j2sdk1.4.2_12 as my library within the project. I've set JAVA_HOME to be "C:\j2sdk1.4.2_12".

Lastly, I'm building the JAR with Red Hat Developer Studio (Beta 1), though this seems to be a fairly common issue with Eclipse in general.

Can anyone offer any insight as to what I'm doing incorrectly?

[ December 12, 2007: Message edited by: Karl Beowulph ]
[ December 12, 2007: Message edited by: Karl Beowulph ]
Joanne Neal

Joined: Aug 05, 2005
Posts: 3742
You cannot put one jar file inside another jar file. You need to put the log4j jar file in the same directory as your jar file and then include it in the classpath setting in your manifest file.
See the manifest section of this for more information.

Michael Breuer

Joined: Nov 18, 2007
Posts: 7
To put a jar inside a jar there is a tricky solution with
onejar OneJar
subject: Eclipse, jars, and noClassDefFoundError
It's not a secret anymore!