package org.jfree.data.general does not exist

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Post Reply
alaw2018
Posts: 1
Joined: Fri Aug 24, 2018 11:09 pm
antibot: No, of course not.

package org.jfree.data.general does not exist

Post by alaw2018 » Sat Aug 25, 2018 1:03 am

I am using JFreeChart to draw a 3D piechart. I am unable to get a clean compilation of my CreateChart class. I get errors stating that org.jfree.data.general and org.jfree.chart.plot do not exist. I cannot understand why I do not this error for org.jfree.chart.ChartPanel and org.jfree.chart.JFreeChart since all files are located in the jfreechart-1.0.19 files I downloaded. I would appreciate whatever help you can provide me. Thanks!
The code is shown below:

import javax.swing.JFrame;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.data.general.PieDataset; //Error: package org.jfree.data.general does not exist
import org.jfree.data.general.DefaultPieDataset; //Error: package org.jfree.data.general does not exist
import org.jfree.chart.plot.PiePlot3D; //Error: package org.jfree.chart.plotl does not exist

public class CreateChart extends JFrame
{
public CreateChart(String appTitle, String chartTitle)
{
PieDataset dataset = createDataset();
JFreeChart chart = createChart(dataset, chartTitle);
ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPreferredSize(new java.awt.Dimension(500, 300));
setContentPane(chartPanel);

}
//Create the dataset:
private PieDataset createDataset()
{
DefaultPieDataset result = new DefaultPieDataset();
result.setValue("Windows", 65);
result.setValue("Linux", 15);
result.setValue("MAC", 20);
return result;
}

private JFreeChart createChart(PieDataset dataset, String title)
{
JFreeChart chart = ChartFactory.createPieChart3D(title, dataset, true, true, false);
PiePlot3D plot = (PiePlot3D)chart.getPlot(); //jfree-->chart-->plot-->PiePlot3D
plot.setStartAngle(0);
plot.setDirection(Rotation.CLOCKWISE);
plot.setForegroundAlpha(0.5f);
return chart;
}

}

John Matthews
Posts: 479
Joined: Wed Sep 12, 2007 3:18 pm

Re: package org.jfree.data.general does not exist

Post by John Matthews » Sat Aug 25, 2018 2:28 am

If you're using JFreeChart 1.0.19, verify that both jfreechart-1.0.19.jar and jcommon-1.0.23.jar are in your class path when compiling.

Code: Select all

export JFREE_HOME=/jfreechart
javac -cp .:$JFREE_HOME/lib/* CreateChart.java …
If you're using JFreeChart 1.5, see Migration from JFreeChart 1.0.x.

Post Reply