• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Chart to.jpeg file.

 
Noopur Kore
Ranch Hand
Posts: 77
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to convert my bar chart which I made in Jfreechart into a .jpeg file. I did some R&D and found this --
and


However When ever I try to run this code. Both gives me this error --
BarExample.java:35: cannot find symbol
symbol : class FileOutputStream/File
location: class BarExample
ChartUtilities.saveChartAsJPEG(new FileOutputStream("D:/java/jdk
1.6.0_16/bin/chart.jpg"), chart, 400, 350);
^

Help!!

Also the path we give here is the place and name of the file where it should be stored, right?? Where Am I going wrong??
 
Jayesh A Lalwani
Rancher
Posts: 2756
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you put an import statement?
 
Noopur Kore
Ranch Hand
Posts: 77
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import org.jfree.chart.ChartUtilities;

done.
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then you didn't put an import statement for the class which the error message is complaining about -- FileOutputStream?
 
Noopur Kore
Ranch Hand
Posts: 77
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import org.jfree.chart.*;
import org.jfree.data.category.*;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.data.xy.*;
import org.jfree.data.*;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.renderer.category.*;
import org.jfree.chart.plot.*;
import java.awt.*;
import java.sql.*;

These are all libraries i imported. which is the one for FileOutputStream?? Or is it giving me a problem because I'm trying to display the chart and save it at the same time??
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Noopur Kore wrote:These are all libraries i imported. which is the one for FileOutputStream??


None of them import FileOutputStream. Have a look at the API documentation (just follow the link from FileOutputStream which will take you directly there) and you'll see what package it's in.

Or is it giving me a problem because I'm trying to display the chart and save it at the same time??


The compiler message says it can't find the symbol "FileOutputStream". That's all it says. The compiler has no idea what any of those classes do or what they are for, so it can't possibly know that there are "charts" involved and that you are trying to "display" the chart or anything of that kind. All it knows is symbols. So when you see an error message, just focus on what it actually says. Don't try to invent meanings for what it says, especially meanings like that one.

 
Noopur Kore
Ranch Hand
Posts: 77
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That did it. Thank you Paul.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic