Reputation: 765
I have this code i'd like to compile , but it refuses to compile , clearly i'm missing a step.
I compile the code below as follow:
javac -cp .:jcommon-1.0.0.jar:jfreechart-1.0.1.jar App.java
The compile error basically:
cannot find org.jfree.data.xy.DefaultXYDataset and precisely DefaultXYDataset.
import java.util.HashSet;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.xy.DefaultXYDataset;
import org.jfree.data.xy.XYDataset;
public class App {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JFrame frame = new JFrame("Charts");
frame.setSize(600, 400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
XYDataset ds = createDataset();
JFreeChart chart = ChartFactory.createXYLineChart("Test Chart",
"x", "y", ds, PlotOrientation.VERTICAL, true, true,
false);
ChartPanel cp = new ChartPanel(chart);
frame.getContentPane().add(cp);
}
});
}
private static XYDataset createDataset() {
DefaultXYDataset ds = new DefaultXYDataset();
double[][] data = { {0.1, 0.2, 0.3}, {1, 2, 3} };
ds.addSeries("series1", data);
return ds;
}
}
What am i missing here ?
Upvotes: 2
Views: 345
Reputation: 5861
You seem to use jfreechart-1.0.1.jar and DefaultXYDataset is present since 1.0.2.
You could download the correct version of jar and try again.
Courtesy: javadoc for Class DefaultXYDataset
Upvotes: 3