Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NoClassDefFound Error in this Java Code

I am facing an error in this code.

import java.awt.Color;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.DefaultCategoryDataset;
public void simplebarchart()
{
   DefaultCategoryDataset dataset=new DefaultCategoryDataset() ;  
   dataset.setValue(80, "Marks", "Student1");
   dataset.setValue(70, "Marks", "Student2");
   dataset.setValue(65, "Marks", "Student3");
   dataset.setValue(90, "Marks", "Student4");
   JFreeChart c=ChartFactory.createBarChart("Student Score" ,"Student Name", "Marks",dataset, 
   PlotOrientation.VERTICAL, false, true, false);
   CategoryPlot p=c.getCategoryPlot();
   p.setRangeGridlinePaint(Color.BLACK);
   ChartFrame frame=new ChartFrame("Bar Chart",c);
   frame.setVisible(true);
   frame.setSize(450, 350);

}

The error is given below

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: 

 org/jfree/util/PublicCloneable
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:792)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)

Why do I get this error?

like image 634
MUHAMMAD BILAL Avatar asked Dec 12 '22 10:12

MUHAMMAD BILAL


1 Answers

Do you have jcommon in your classpath?

If not, simply add jCommon to your classpath and your problem should be solved.

Searches on the web suggests this answer frequently.

like image 140
Rawa Avatar answered Jan 04 '23 16:01

Rawa