File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other Open Source Projects and the fly likes Chart to.jpeg file. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Chart to.jpeg file." Watch "Chart to.jpeg file." New topic
Author

Chart to.jpeg file.

Noopur Kore
Ranch Hand

Joined: Aug 18, 2012
Posts: 77

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
Bartender

Joined: Jan 17, 2008
Posts: 2376
    
  28

Did you put an import statement?
Noopur Kore
Ranch Hand

Joined: Aug 18, 2012
Posts: 77

import org.jfree.chart.ChartUtilities;

done.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

Then you didn't put an import statement for the class which the error message is complaining about -- FileOutputStream?
Noopur Kore
Ranch Hand

Joined: Aug 18, 2012
Posts: 77

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
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

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

Joined: Aug 18, 2012
Posts: 77

That did it. Thank you Paul.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Chart to.jpeg file.