NoClassDefFoundError

A discussion forum for the JCommon class library.
Post Reply
RoyT
Posts: 3
Joined: Tue Mar 01, 2005 3:00 pm
Location: Leeds, UK

NoClassDefFoundError

Post by RoyT » Tue Mar 01, 2005 3:05 pm

Hi, I cannot understand why I get the above error when running my java app under Apache Tomcat, when the compile picks up the class ok. The class in question is FloatDimension.
I have set up my classpath to include jcommon-0.9.7.jar, and I have code containing
import org.jfree.ui.FloatDimension;

and
factory.setMinimumSize(new FloatDimension(150, 20));

The class is obviously picked up at compile, but then falls over when initialising the class containing the above code.

Any ideas please?

djr10007a

same for me...

Post by djr10007a » Mon Mar 21, 2005 6:45 am

Just curious, did you solve this yet?

I am having a similar problem using Eclipse. Under the IDE, my application runs fine, but when I export it to an executable JAR, I get the NoClassDefFound error like you.

I wish to generate a single executable jar containing the jfreechart classes, but can't seem to get it to happen!

RoyT
Posts: 3
Joined: Tue Mar 01, 2005 3:00 pm
Location: Leeds, UK

Post by RoyT » Mon Mar 21, 2005 10:56 am

Hi

My problem was caused by Apache Tomcat not using the classpath. When I put the jar file into the lib directory then it all worked.

Best of luck with your problem.

RoyT

cassidyh
Posts: 10
Joined: Mon Jun 27, 2005 1:19 pm
Location: MD
Contact:

Post by cassidyh » Mon Jun 27, 2005 2:43 pm

I am having the same problem with running my app from Eclipse is fine, but when I create a jar, nothing happens. SOmebody please help

RoyT
Posts: 3
Joined: Tue Mar 01, 2005 3:00 pm
Location: Leeds, UK

Post by RoyT » Mon Jun 27, 2005 3:06 pm

Hi cassidyh.

I am sorry but I do not know anything about Eclipse or how it sets its classpath or where appropriate files should be stored.

RoyT

Mimil
JFreeReport Staff Member
Posts: 69
Joined: Tue Mar 25, 2003 7:33 pm

Post by Mimil » Tue Jun 28, 2005 3:35 pm

Hi,

Tell us a bite more about how you are doing perhaps it will be easier.
But jars need classes to be also in the path, so did you do this properly?
A student of JFree & Pentaho Academies

Bye,
Cedric Pronzato

cassidyh
Posts: 10
Joined: Mon Jun 27, 2005 1:19 pm
Location: MD
Contact:

eclipse problems

Post by cassidyh » Tue Jun 28, 2005 3:44 pm

I actually had to extract all source files from Jcommon.jar as well as from jfreechart.jar and add it to my project before I packed it into a self-executable jar file. That is the only way to make the code portable. It is also ridiculous...I mean, what's the point of using a jar file for classes, if the jar utility won't pack the jar files with it. And yes, I did have all necessary jar files on my build path. Now, I can transport my code into a self-executable, but I am not very happy about having to add all the source and class files to my jar instead of just the jar files. Maybe this is an Eclipse bug.....don't know
cass

Mimil
JFreeReport Staff Member
Posts: 69
Joined: Tue Mar 25, 2003 7:33 pm

Post by Mimil » Tue Jun 28, 2005 3:51 pm

Hi,

As for me, and my understanding of java, you will have to carry all the jars. You can't include jars in an other jar. But you can set a classpath attribut in your manifest to tell where are located the other jars (and it can be relative).
A student of JFree & Pentaho Academies

Bye,
Cedric Pronzato

cassidyh
Posts: 10
Joined: Mon Jun 27, 2005 1:19 pm
Location: MD
Contact:

Post by cassidyh » Tue Jun 28, 2005 3:59 pm

HOw do write that into the manifest file? I am not so sure about how to do it, but that would be great. I appreciate any help, because my way works, but it is by far not very effective at all.

Mimil
JFreeReport Staff Member
Posts: 69
Joined: Tue Mar 25, 2003 7:33 pm

Post by Mimil » Tue Jun 28, 2005 4:04 pm

Hi,

here is an exemple of one auto generated by ant:

Code: Select all

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.2
Created-By: 1.2.2 (Sun Microsystems Inc.)
Class-Path: lib/jcommon-1.0.0-rc1.jar lib/pixie-0.8.4.jar
Here is the reference doc : http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html
A student of JFree & Pentaho Academies

Bye,
Cedric Pronzato

Vincent643

Post by Vincent643 » Thu Sep 15, 2005 12:53 pm

You can't include jars in an other jar.
Thank you Mimil for this! Thanks a lot, that is exaclty what I was looking for.

Vincent

Taqua
JFreeReport Project Leader
Posts: 698
Joined: Fri Mar 14, 2003 3:34 pm
Contact:

Post by Taqua » Thu Sep 15, 2005 3:19 pm

Well,

actually, there is a way to create such jars. It involves writing an own Classloader that accesses the jars stored inside. That's the deepest black magic possibly imaginable. But as usual: Someone already did it.

http://classworlds.codehaus.org/uberjar.html

Regards,
Thomas

Post Reply