943,600 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 2356
  • Java RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Jul 2nd, 2009
0

Re: can't install JFreechart

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:
Java Syntax (Toggle Plain Text)
  1. import java.awt.Graphics2D;
  2. import java.awt.Graphics;
  3. import java.awt.event.ActionEvent;
  4. import java.awt.event.ActionListener;
  5. import java.awt.geom.Rectangle2D;
  6. import java.awt.image.BufferedImage;
  7.  
  8. import javax.swing.*;
  9.  
  10. import org.jfree.chart.ChartFactory;
  11. import org.jfree.chart.JFreeChart;
  12. import org.jfree.data.general.DefaultPieDataset;
  13.  
  14. public class Test extends JFrame{
  15. Test ts;
  16. public Test(){
  17. ts=this;
  18. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  19. setSize(400,400);
  20. setVisible(true);
  21. }
  22.  
  23. public void run() {
  24. // create a dataset...
  25. final DefaultPieDataset data = new DefaultPieDataset();
  26. data.setValue("One", new Double(10.3));
  27. data.setValue("Two", new Double(8.5));
  28. data.setValue("Three", new Double(3.9));
  29. data.setValue("Four", new Double(3.9));
  30. data.setValue("Five", new Double(3.9));
  31. data.setValue("Six", new Double(3.9));
  32.  
  33. // create a pie chart...
  34. final boolean withLegend = true;
  35. final JFreeChart chart = ChartFactory.createPieChart(
  36. "Testing",
  37. data,
  38. withLegend,
  39. true,
  40. false
  41. );
  42. final Graphics2D g2 = (Graphics2D) ts.getGraphics();
  43. final Rectangle2D chartArea = new Rectangle2D.Double(0, 0, 400, 300);
  44.  
  45. chart.draw(g2, chartArea, null, null);
  46. }
  47. public static void main(String[] args) {
  48. Test app = new Test();
  49. app.run();
  50. }
  51. }

To compile Test.java & Launch Test class
Java Syntax (Toggle Plain Text)
  1. >javac -classpath .;c:\jlib\jfreechart-1.0.13
  2. .jar;c:\jlib\iText-2.1.5.jar;c:\jlib\jcommon-1.0.16.jar Test.java
  3.  
  4. >java -classpath .;c:\jlib\jfreechart-1.0.13.
  5. jar;c:\jlib\iText-2.1.5.jar;c:\jlib\jcommon-1.0.16.jar Test
Moderator
Reputation Points: 2136
Solved Threads: 1228
Posting Genius
adatapost is offline Offline
6,527 posts
since Oct 2008
Jul 3rd, 2009
0

Re: can't install JFreechart

Click to Expand / Collapse  Quote originally posted by di2daer ...
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
Last edited by anusha88; Jul 3rd, 2009 at 2:41 am.
Reputation Points: 10
Solved Threads: 0
Light Poster
anusha88 is offline Offline
28 posts
since Jun 2009
Jul 3rd, 2009
0

Re: can't install JFreechart

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?
Reputation Points: 10
Solved Threads: 0
Light Poster
anusha88 is offline Offline
28 posts
since Jun 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: url case sensitive
Next Thread in Java Forum Timeline: Frame and Multiple Panel ..Need Help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC