此 Java 代码中的 NoClassDefFound 错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19723843/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 19:42:41  来源:igfitidea点击:

NoClassDefFound Error in this Java Code

javajfreechart

提问by MUHAMMAD BILAL

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.access0(URLClassLoader.java:71)

Why do I get this error?

为什么我会收到这个错误?

回答by Rawa

Do you have jcommon in your classpath?

你的类路径中有 jcommon 吗?

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

如果没有,只需将 jCommon 添加到您的类路径中,您的问题就会得到解决。

Searches on the web suggests this answer frequently.

网络上的搜索经常建议这个答案。