This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
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

Win a copy of Head First Android this week in the Android forum!
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
I agree. Here's the link:
subject: Eclipse, jars, and noClassDefFoundError
It's not a secret anymore!