我已经将JFreeChart演示的编码复制并创建到我在项目中创建的类中。
当我尝试编译代码时收到java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: (<any>)void
。
完整错误如下:
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: (<any>)void
at JFreeChartExample.<init>(JFreeChartExample.java:32)
at JFreeChartExample.main(JFreeChartExample.java:45)
Java Result: 1
Line java:32 -plot.setDirection(Rotation.CLOCKWISE);
如果我打开代码并在setDirection上突出显示,则会显示The type of setDirection(Rotation) is erroneous
以下是演示的编码。
import javax.swing.JFrame;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PiePlot;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.util.Rotation;
public class JFreeChartExample extends JFrame {
public JFreeChartExample(String frameTitle, String chartTitle) {
super(frameTitle);
//Creates a sample defaultPieDataset
DefaultPieDataset defaultPieDataset = new DefaultPieDataset();
defaultPieDataset.setValue("c/c++", 19);
defaultPieDataset.setValue("java", 46);
defaultPieDataset.setValue("php", 35);
// based on the defaultPieDataset we create the chart
JFreeChart pieChart = ChartFactory.createPieChart3D(chartTitle, defaultPieDataset, true, true, false);
PiePlot plot = (PiePlot) pieChart.getPlot();
plot.setStartAngle(290);
plot.setDirection(Rotation.CLOCKWISE);
plot.setForegroundAlpha(0.5f);
// Adding chart into a chart panel
ChartPanel chartPanel = new ChartPanel(pieChart);
// setting default size
chartPanel.setPreferredSize(new java.awt.Dimension(300, 200));
// add to contentPane
setContentPane(chartPanel);
}
public static void main(String[] args) {
JFreeChartExample chart = new JFreeChartExample("Language Usage Statistics", "Which language are you Learning?");
chart.pack();
chart.setVisible(true);
}
}
我已将jcommon-1.018.jar和jfreechart-1.0.15.jar库导入到我的项目中。
我注意到的是,如果我为这个演示创建一个完整的新项目,它可以正常工作,但是当我将它合并到我现有的项目中时,我收到了这个错误。
任何帮助将不胜感激!
由于
当我导航到源
时 public void setDirection(Rotation direction) {
// <editor-fold defaultstate="collapsed" desc="Compiled Code">
/* 0: new #3 // class java/lang/RuntimeException
* 3: dup
* 4: ldc #4 // String Uncompilable source code - cannot find symbol\n symbol: class Rotation\n location: class org.jfree.chart.plot.PiePlot
* 6: invokespecial #5 // Method java/lang/RuntimeException."<init>":(Ljava/lang/String;)V
* 9: athrow
* */
// </editor-fold>
}