Applets - java.lang.NoClassDefFoundError

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
jim canniff

Applets - java.lang.NoClassDefFoundError

Post by jim canniff » Mon Feb 10, 2003 10:35 pm

Hi all,

I'm just getting started with JFreeChart and was able to compile and run the PieChart demo after adding the JCommon.jar, JFreeChart.jar and the "." to my CLASSPATH.

However, I can't get any applets to run properly. I'm getting all "java.lang.NoClassDefFoundError" messages when I try to run them. Mostly the message says the class can't find itself (wrong name?) or sometimes it's a class file from one of the jar files (I'm assuming). Anyway, they compile fine but I get the same error whether I reference and try to run them in a browser or if I just run it through an IDE's Applet Viewer (i'm using JBuilder and TextPad).

Anyway, if there is something else I need to add to the Path or CLASSPATH, or anything else I need to do, please advise.

Thanks very much,
Jim

David Gilbert

Re: Applets - java.lang.NoClassDefFoundError

Post by David Gilbert » Tue Feb 11, 2003 10:09 am

There is an applet demo online at:

http://www.object-refinery.com/jfreechart/applet.html

Does that run for you? If so, take a look at the applet tag in the underlying HTML to see how I specified the classpath. I've used three jar files, one containing the applet plus the JFreeChart and JCommon jar files.

Regards,

Dave Gilbert

jim canniff

Re: Applets - java.lang.NoClassDefFoundError

Post by jim canniff » Tue Feb 11, 2003 4:41 pm

Still getting the same problem for Applet1:
java.lang.NoClassDefFoundError: com/jrefinery/data/TimePeriod

Again, it compiles fine but when I try to include it and run it in a browser (or IDE Applet Viewer), I get the above error. I included it in a jar file this time but it made no difference. Here's the html code:
<APPLET
ARCHIVE="jfreechart-0.9.4-premium- demo.jar,jfreechart-0.9.4.jar,jcommon-0.7.1.jar"
CODE="Applet1"
CODEBASE="com\jrefinery\chart\demo\premium"
width="640" height="260"
ALT="You should see an applet, not this text.">
</APPLET>

The premium jar file contains only the Applet1.class compiled from your source code. By the way, MemoryUsage works fine on my machine as an application.

Thanks for the help,
Jim

jim canniff

Re: Applets - java.lang.NoClassDefFoundError

Post by jim canniff » Wed Feb 12, 2003 4:27 pm

I made some progress but still have not gotten the Applet1 applet to work.

Here's what I did:
To test that I was referencing things properly I made a very simple HelloWorld type swing applet (TestApplet). Then added that to the jfreechart-0.9.4-demo.jar file. Then referencing it with this code in the html I got it to work:
<APPLET
CODE="TestApplet"
CODEBASE="com/jrefinery/chart/demo"
ARCHIVE="jfreechart-0.9.4-demo.jar,jfreechart-0.9.4.jar,jcommon-0.7.1.jar"
width="640" height="260"
ALT="You should see an applet, not this text.">
</APPLET>

So based on this success (albeit small) I moved the Applet1.java file to the com/jrefinery/chart/demo folder, compiled it and added the resulting Applet1.class and Applet1$DataGenerator.class to the jfreechart-0.9.4-demo.jar file. Then I referenced it in the html like this:
<APPLET
CODE="Applet1"
CODEBASE="com/jrefinery/chart/demo"
ARCHIVE="jfreechart-0.9.4-demo.jar,jfreechart-0.9.4.jar,jcommon-0.7.1.jar"
width="640" height="260"
ALT="You should see an applet, not this text.">
</APPLET>

Figuring it's in the same location as the TestApplet (above), it should have displayed but no, I still get the following error:
java.lang.NoClassDefFoundError: Applet1 (wrong name: com/jrefinery/chart/demo/Applet1)

So, any idea what I am doing wrong? Do I need to do something special with the Applet1$DataGenerator.class? I'm perplexed. Thanks for your help.

-Jim

Locked