This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach 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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Eclipse, jars, and noClassDefFoundError" Watch "Eclipse, jars, and noClassDefFoundError" New topic
Author

Eclipse, jars, and noClassDefFoundError

Karl Beowulph
Ranch Hand

Joined: May 31, 2004
Posts: 130
Hello.

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

.classpath


Manifest.mf


Jar contents
.classpath
.project
HelloWorld.class helloWorld\
HelloWorld.java helloWorld\
log4j.jar lib\
Manifest.mf 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
Rancher

Joined: Aug 05, 2005
Posts: 3419
    
  12
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.


Joanne
Michael Breuer
Greenhorn

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: http://aspose.com/file-tools
 
subject: Eclipse, jars, and noClassDefFoundError
 
Similar Threads
The jar synchronization issue seems to be out of hand.
Eclipse projects on removable media
Axis 1.4 Deployment on Websphere5.1 issue
JSTL Tag lib queries
JUnit Test