i need to install JfreeChart but I can't understand much of what the installation manual says.

Which folder should you extract the Jfreechart files.How to change the classpath etc?

I can't seem to understand.terribly stuck!!can anyone please help

i have extracted the file using -xvf command.
But whenevr i try to run the demo using
java -jar jfreechart-1.0.13-demo.jar

it says "unable to access file.".also i can't understand ant compile command.can someone tell me the easiest way to install JFreechart

Did you download common lib along with jfreechart?

no,i havn't.

I have downloaded Jcommon now.Though it said installing Jcommon wasd optional.But i still face the same problem.

Please help.I'm badly stuck.

If you're using eclipse you can choose to add them as external jars.
Right click the project and select build path-> configure build path -> (Libraries tab) add external jars.

no,im not using eclipse or net beans.how to go about then?

Do you use any editor?
If you're running in cmd prompt I think you need to include the location of the jars when you run it, like: java -classpath C:\jfreechart\jfreechart.jar yourApp.java
You can also create a batch script to run it, then you won't have to specify the paths all the time.

i have set the classpath using path in environment variable.and also tried

javac -classpath C:\Documents and Settings\Administrator\jfreechart-1.0.13\lib\jfreechart-1.013.jar myapplication.java

but the compiler still does not recognise jfreechart.

What should i do?

Surron the path with "" and try again.
If that doesn't work, make sure you have all the dependencies included, separate them with ';'

This works for me:
C:\java\Playground\src> javac -classpath C:\jars\jfreechart-1.0.
12.jar;C:\jars\jcommon-1.0.15.jar DrawGraph.java

Add the classpath reference of following JAR:
jfreechart-1.0.13.jar
jcommon-1.0.16.jar lib
iText-2.1.5.jar lib
jfreechart-1.0.13-experimental.jar

A sample chart program:

import java.awt.Graphics2D;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;

import javax.swing.*;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.data.general.DefaultPieDataset;

public class Test extends JFrame{
    Test ts;
    public Test(){
          ts=this;
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          setSize(400,400);
          setVisible(true);
    }

    public void run() {
        // create a dataset...
        final DefaultPieDataset data = new DefaultPieDataset();
        data.setValue("One", new Double(10.3));
        data.setValue("Two", new Double(8.5));
        data.setValue("Three", new Double(3.9));
        data.setValue("Four", new Double(3.9));
        data.setValue("Five", new Double(3.9));
        data.setValue("Six", new Double(3.9));

        // create a pie chart...
        final boolean withLegend = true;
        final JFreeChart chart = ChartFactory.createPieChart(
            "Testing", 
            data, 
            withLegend,
            true,
            false
        );
         final Graphics2D g2 = (Graphics2D) ts.getGraphics();
        final Rectangle2D chartArea = new Rectangle2D.Double(0, 0, 400, 300);
        
        chart.draw(g2, chartArea, null, null);
    }
     public static void main(String[] args) {
        Test app = new Test();
        app.run();
    }
}

To compile Test.java & Launch Test class

>javac -classpath .;c:\jlib\jfreechart-1.0.13
.jar;c:\jlib\iText-2.1.5.jar;c:\jlib\jcommon-1.0.16.jar Test.java

>java -classpath .;c:\jlib\jfreechart-1.0.13.
jar;c:\jlib\iText-2.1.5.jar;c:\jlib\jcommon-1.0.16.jar Test

Surron the path with "" and try again.
If that doesn't work, make sure you have all the dependencies included, separate them with ';'

This works for me:
C:\java\Playground\src> javac -classpath C:\jars\jfreechart-1.0.
12.jar;C:\jars\jcommon-1.0.15.jar DrawGraph.java

hey thanks a lot...Sorry for the stupid questions asked.I'm a fairly new programmer.

the application file is compiled but when i try to run it it gives a "noclassdeffound" exception in main even when i have specified the classpath

my class file is in the current directory but still it gives this error.
i compiled using

C:\Documents and Settings\Administrator>javac -classpath C:\jfreechart-1.0.13\li
b\jfreechart-1.0.13.jar;C:\jfreechart-1.0.13\lib\jcommon-1.0.16.jar PolarDemo.ja
va

the class file after compiling resides in C:\Documents and Settings\Administrator directory still when i try to run it using

C:\Documents and Settings\Administrator>java -classpath C:\jfreechart-1.0.13\lib
\jfreechart-1.0.13.jar;C:\jfreechart-1.0.13\lib\jcommon-1.0.16.jar PolarDemo
Exception in thread "main" java.lang.NoClassDefFoundError: PolarDemo
Caused by: java.lang.ClassNotFoundException: PolarDemo
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: PolarDemo. Program will exit.

I get this error.Where am i going wrong?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.