Compilation Error

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
orlando.boomi
Posts: 1
Joined: Mon Dec 26, 2011 8:59 am
antibot: No, of course not.

Compilation Error

Post by orlando.boomi » Mon Dec 26, 2011 9:24 am

Hi all,
I am getting error while compiling the below code(javac PieChartDemo.java).
PieChartDemo.java
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.general.DefaultPieDataset;

public class PieChartDemo {
public static void main(String[] args) {
writeChartToPDF(generateBarChart(), 500, 400, "/media/abc/output1.pdf");
writeChartToPDF(generateBarChart(), 500, 400, "/media/abc/output2.pdf");
}
public static void writeChartToPDF(JFreeChart chart, int width, int height, String fileName) {
PdfWriter writer = null;

Document document = new Document();

try {
writer = PdfWriter.getInstance(document, new FileOutputStream(
fileName));
document.open();
PdfContentByte contentByte = writer.getDirectContent();
PdfTemplate template = contentByte.createTemplate(width, height);
Graphics2D graphics2d = template.createGraphics(width, height,
new DefaultFontMapper());
Rectangle rectangle = new Rectangle.Double(0, 0, width,
height);

chart.draw(graphics2d, rectangle);

graphics2d.dispose();
contentByte.addTemplate(template, 0, 0);

} catch (Exception e) {
e.printStackTrace();
}
document.close();
}

public static JFreeChart generatePieChart() {
DefaultPieDataset dataSet = new DefaultPieDataset();
dataSet.setValue("China", 19.64);
dataSet.setValue("India", 17.3);
dataSet.setValue("United States", 4.54);
dataSet.setValue("Indonesia", 3.4);
dataSet.setValue("Brazil", 2.83);
dataSet.setValue("Pakistan", 2.48);
dataSet.setValue("Bangladesh", 2.38);

JFreeChart chart = ChartFactory.createPieChart(
"World Population by countries", dataSet, true, true, false);

return chart;
}

public static JFreeChart generateBarChart() {
DefaultCategoryDataset dataSet = new DefaultCategoryDataset();
dataSet.setValue(791, "Population", "1750 AD");
dataSet.setValue(978, "Population", "1800 AD");
dataSet.setValue(1262, "Population", "1850 AD");
dataSet.setValue(1650, "Population", "1900 AD");
dataSet.setValue(2519, "Population", "1950 AD");
dataSet.setValue(6070, "Population", "2000 AD");

JFreeChart chart = ChartFactory.createBarChart(
"World Population growth", "Year", "Population in millions",
dataSet, PlotOrientation.VERTICAL, false, true, false);

return chart;
}
}
Error :
PieChartDemo.java:3: package org.jfree.chart does not exist
import org.jfree.chart.ChartFactory;
^
PieChartDemo.java:4: package org.jfree.chart does not exist
import org.jfree.chart.JFreeChart;
^
PieChartDemo.java:5: package org.jfree.chart.plot does not exist
import org.jfree.chart.plot.PlotOrientation;
^
PieChartDemo.java:6: package org.jfree.data.category does not exist
import org.jfree.data.category.DefaultCategoryDataset;
^
PieChartDemo.java:7: package org.jfree.data.general does not exist
import org.jfree.data.general.DefaultPieDataset;
^
PieChartDemo.java:15: cannot find symbol
symbol : class JFreeChart
location: class PieChartDemo
public static void writeChartToPDF(JFreeChart chart, int width, int height, String fileName) {
^
PieChartDemo.java:42: cannot find symbol
symbol : class JFreeChart
location: class PieChartDemo
public static JFreeChart generatePieChart() {
^
PieChartDemo.java:58: cannot find symbol
symbol : class JFreeChart
location: class PieChartDemo
public static JFreeChart generateBarChart() {
^
PieChartDemo.java:16: cannot find symbol
symbol : class PdfWriter
location: class PieChartDemo
PdfWriter writer = null;
^
PieChartDemo.java:18: cannot find symbol
symbol : class Document
location: class PieChartDemo
Document document = new Document();
^
PieChartDemo.java:18: cannot find symbol
symbol : class Document
location: class PieChartDemo
Document document = new Document();
^
PieChartDemo.java:21: cannot find symbol
symbol : class FileOutputStream
location: class PieChartDemo
writer = PdfWriter.getInstance(document, new FileOutputStream(
^
PieChartDemo.java:21: cannot find symbol
symbol : variable PdfWriter
location: class PieChartDemo
writer = PdfWriter.getInstance(document, new FileOutputStream(
^
PieChartDemo.java:24: cannot find symbol
symbol : class PdfContentByte
location: class PieChartDemo
PdfContentByte contentByte = writer.getDirectContent();
^
PieChartDemo.java:25: cannot find symbol
symbol : class PdfTemplate
location: class PieChartDemo
PdfTemplate template = contentByte.createTemplate(width, height);
^
PieChartDemo.java:26: cannot find symbol
symbol : class Graphics2D
location: class PieChartDemo
Graphics2D graphics2d = template.createGraphics(width, height,
^
PieChartDemo.java:27: cannot find symbol
symbol : class DefaultFontMapper
location: class PieChartDemo
new DefaultFontMapper());
^
PieChartDemo.java:28: cannot find symbol
symbol : class Rectangle
location: class PieChartDemo
Rectangle rectangle = new Rectangle.Double(0, 0, width,
^
PieChartDemo.java:28: package Rectangle does not exist
Rectangle rectangle = new Rectangle.Double(0, 0, width,
^
PieChartDemo.java:43: cannot find symbol
symbol : class DefaultPieDataset
location: class PieChartDemo
DefaultPieDataset dataSet = new DefaultPieDataset();
^
PieChartDemo.java:43: cannot find symbol
symbol : class DefaultPieDataset
location: class PieChartDemo
DefaultPieDataset dataSet = new DefaultPieDataset();
^
PieChartDemo.java:52: cannot find symbol
symbol : class JFreeChart
location: class PieChartDemo
JFreeChart chart = ChartFactory.createPieChart(
^
PieChartDemo.java:52: cannot find symbol
symbol : variable ChartFactory
location: class PieChartDemo
JFreeChart chart = ChartFactory.createPieChart(
^
PieChartDemo.java:59: cannot find symbol
symbol : class DefaultCategoryDataset
location: class PieChartDemo
DefaultCategoryDataset dataSet = new DefaultCategoryDataset();
^
PieChartDemo.java:59: cannot find symbol
symbol : class DefaultCategoryDataset
location: class PieChartDemo
DefaultCategoryDataset dataSet = new DefaultCategoryDataset();
^
PieChartDemo.java:67: cannot find symbol
symbol : class JFreeChart
location: class PieChartDemo
JFreeChart chart = ChartFactory.createBarChart(
^
PieChartDemo.java:69: cannot find symbol
symbol : variable PlotOrientation
location: class PieChartDemo
dataSet, PlotOrientation.VERTICAL, false, true, false);
^
PieChartDemo.java:67: cannot find symbol
symbol : variable ChartFactory
location: class PieChartDemo
JFreeChart chart = ChartFactory.createBarChart(

Please tell me what is the solution for this error?
Thank you :)

Efren23
Posts: 3
Joined: Wed Jan 11, 2012 8:48 am
antibot: No, of course not.

Re: Compilation Error

Post by Efren23 » Thu Jan 12, 2012 5:57 am

Hi, I'm novice with postgreSQL and I want to install it. I have
a Sun machine with SunOS 4.1.3.

While I'm compiling, it shows the next error message:

gmake[2]: Entering directory
`/usr/share/src/pgsql/postgresql-6.3.2/src/backend/parser'
/bin/yacc -d gram.y

fatal error: more than 600 rules, line 3318
gmake[2]: *** [parse.h] Error 1
gmake[2]: Leaving directory
`/usr/share/src/pgsql/postgresql-6.3.2/src/backend/parser'
gmake[1]: *** [parser.dir] Error 2
gmake[1]: Leaving directory
`/usr/share/src/pgsql/postgresql-6.3.2/src/backend'
gmake: *** [all] Error 2

What is the problem?
Thanks in advance.

tomicrow
Posts: 1
Joined: Thu May 11, 2017 8:08 am
antibot: No, of course not.

Re: Compilation Error

Post by tomicrow » Thu May 11, 2017 8:09 am

The "Cannot find symbol" errors generally occur when you try to reference an undeclared variable in your code. A "Cannot find symbol" error means that the compiler cannot do this. Your code appears to be referring to something that the compiler doesn't understand.

What things can cause this error?

The general causes for a Cannot find symbol error are things like:

Incorrect spelling.
Wrong case. Halo is different from halo.
Improper use of acceptable identifier values (letters, numbers, underscore, dollar sign), my-class is not the same as myclass.
No variable declaration or variable is outside of the scope you are referencing it in.

More about...cannot find symbol Error

Crow

Locked