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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With