I had a java program which uses jfreechart API to create histogram, which is running fine in windows system but the same is not running in unix system. It is saying NoClassDef exception. I have added the jfreechart jar to the lib in Unix... Do I need to do anything else to make it run?
-
NO... Nothing more... – Parth Soni Mar 13 '13 at 12:24
-
@codeMaker: `jcommon` is required, too. – trashgod Mar 13 '13 at 13:39
2 Answers
NoClassDef exceptions are really only thrown for the fact the class simply doesn't exist.
Are you running the application through an IDE? If so, make sure the jar is in the classpath. If not, make sure you're including it in the command prompt.
java -classpath thirdpartyjar.jar mainclass.java
There can be no reason for this exception other than the class doesn't exist or the lib is in the wrong place.

- 19,577
- 28
- 108
- 128
Be sure that both the jfreechart
and jcommon
JARs are on the classpath
, along with your class.
In this example, the required libraries are cited in the Class-Path
attribute of the JAR's manifest:
$ java -cp jfreechart-1.0.14-demo.jar demo.BarChartDemo1
In this example, DTSCTest.class
is in build/classes
, the the libraries are in dist/lib
:
$ java -cp build/classes:dist/lib/* chart.DTSCTest
See java
for details.