-2

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?

Beau Grantham
  • 3,435
  • 5
  • 33
  • 43
user2057312
  • 33
  • 1
  • 2

2 Answers2

1

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.

David
  • 19,577
  • 28
  • 108
  • 128
1

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.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045