Results 1 to 12 of 12
  1. #1
    Rami is offline Member
    Join Date
    Jul 2011
    Posts
    28
    Rep Power
    0

    Default Adding jfreechart

    Hi.
    I downloaded jfreechart as a zipped file, where exactly should I extract it to become able to use it?
    Thanks!

  2. #2
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,058
    Rep Power
    5

    Default

    You can extract it anywhere. I use Linux, and I like to keep Java jars in $HOME/lib/java.

    To run a program from the command line that uses a jar, include the jar file in the -cp switch:

    Java Code:
     java -cp .:/path/to/jfreechart.jar package.ClassToRun
    The "." in the classpath means the current directory. The ":" separates locations in the classpath. Be aware that the path separator is different on different systems. I think it's ";" on Windows. Also, the directory separators are different. Your cp might be ".;C:\java\jars\jfreechart.jar" or something.

    Newer versions of the JVM (since 1.6, I think) can also use wildcards in the classpath. So if you have a directory full of jars, you can use /path/to/jars/*.jar in your classpath.
    Last edited by kjkrum; 08-18-2011 at 08:18 AM.
    Get in the habit of using standard Java naming conventions!

  3. #3
    Rami is offline Member
    Join Date
    Jul 2011
    Posts
    28
    Rep Power
    0

    Default

    THANKS :D
    This should be written in tutorials for begginers like myself!
    You've been of amazing help! thank you!

  4. #4
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,058
    Rep Power
    5

    Default

    I'm sure it is written in a tutorial somewhere. Some people on these forums will just post links as answers. But sometimes I like to write my own answers. Forcing myself to think about the answers keeps me sharp. :)
    Get in the habit of using standard Java naming conventions!

  5. #5
    Rami is offline Member
    Join Date
    Jul 2011
    Posts
    28
    Rep Power
    0

    Default

    Thanks! It's the right to do I think :)
    But I tried to try a code from the Internet using jfreecharts to start getting familiar with it, and I got an exception that says:
    Java Code:
    Exception in thread "main" java.lang.NoSuchMethodError: org.jfree.ui.RectangleInsets.<init>(DDDD)V
        at org.jfree.chart.axis.Axis.<clinit>(Axis.java:146)
        at org.jfree.chart.StandardChartTheme.<init>(StandardChartTheme.java:227)
        at org.jfree.chart.ChartFactory.<clinit>(ChartFactory.java:229)
        at pie.main(pie.java:22)
    is it a problem with the code? there's one simple sample I tried:

    Java Code:
    import java.awt.*;
     import org.jfree.chart.*;
     import org.jfree.chart.title.*;
     import org.jfree.data.general.DefaultPieDataset;
     import org.jfree.ui.*;
     import org.jfree.chart.plot.*;
     import org.jfree.util.*;
     
    public class pie{
     public static void main(String arg[]){
       DefaultPieDataset pieDataset = new DefaultPieDataset();
       pieDataset.setValue("One", new Integer(10));
       pieDataset.setValue("Two", new Integer(20));
       pieDataset.setValue("Three", new Integer(30));
       pieDataset.setValue("Four", new Integer(10));
       pieDataset.setValue("Five", new Integer(20));
       pieDataset.setValue("Six", new Integer(10));
       JFreeChart chart = ChartFactory.createPieChart3D
       ("3D Pie Chart", pieDataset, true,true,true);
       PiePlot3D p=(PiePlot3D)chart.getPlot();
       p.setForegroundAlpha(0.5f);
       ChartFrame frame1=new ChartFrame("3D Pie Chart",chart);
       frame1.setVisible(true);
       frame1.setSize(300,300);
       }
     }

  6. #6
    Rami is offline Member
    Join Date
    Jul 2011
    Posts
    28
    Rep Power
    0

    Default

    Yea, and I didnt know where should I go to read about it and how to use it. I thought I wouldve tried to know the problem from reading about it.

  7. #7
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,058
    Rep Power
    5

    Default

    NoSuchMethodError happens when you take a program compiled against one version of a library and run it with a different version of the library that's missing a method. If you tried to recompile the program, you'd get a compiler error.

    A good thing to do when you get error messages is read about the error class in the API docs. Just Google "java nosuchmethoderror 6" or whatever. The "6" is because I'm interested in the docs for Java 1.6. (1.7 just came out, and I don't trust it yet.)
    Get in the habit of using standard Java naming conventions!

  8. #8
    Rami is offline Member
    Join Date
    Jul 2011
    Posts
    28
    Rep Power
    0

    Default

    So I have got missing methods? Is this the problem?
    Then where can I go to know the methods available for me?
    i have jdk 7. But for some reasons I dont know I dont have some libraries in the java 1.7..
    Thanks

  9. #9
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,058
    Rep Power
    5

    Default

    So you're compiling your own code, and it compiles without error, but then you get a NoSuchMethodError when you run it? That's weird. Maybe there's a version mismatch between classes inside the jfreechart jar.
    Get in the habit of using standard Java naming conventions!

  10. #10
    Rami is offline Member
    Join Date
    Jul 2011
    Posts
    28
    Rep Power
    0

    Default

    Yes I get no compilation errors.
    So the problem in the jfreecharts zipped file i downloaded? Im sorry because Im not getting it clearly :)

  11. #11
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,058
    Rep Power
    5

    Default

    That would be my first guess, yes.
    Get in the habit of using standard Java naming conventions!

  12. #12
    Rami is offline Member
    Join Date
    Jul 2011
    Posts
    28
    Rep Power
    0

    Default

    Ok thanks!
    If it did not work Ill come again and post another thread :)
    Thanks alot!

Similar Threads

  1. JFreeChart 1.0.11
    By Java Tip in forum Java Software
    Replies: 3
    Last Post: 04-18-2014, 08:27 PM
  2. Jfreechart
    By aaruviswa in forum Web Frameworks
    Replies: 2
    Last Post: 03-17-2011, 06:51 AM
  3. JfreeChart
    By puk284 in forum Advanced Java
    Replies: 1
    Last Post: 05-12-2009, 04:52 PM
  4. Replies: 5
    Last Post: 02-25-2009, 08:01 AM
  5. JFreeChart 1.0.8
    By JavaBean in forum Java Software
    Replies: 0
    Last Post: 11-27-2007, 08:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •