can't install JFreechart

Reply

Join Date: Oct 2008
Posts: 2,612
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 463
Moderator
adatapost's Avatar
adatapost adatapost is offline Offline
Posting Maven

Re: can't install JFreechart

 
0
  #11
Jul 2nd, 2009
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:
  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
  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
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 28
Reputation: anusha88 is an unknown quantity at this point 
Solved Threads: 0
anusha88 anusha88 is offline Offline
Light Poster

Re: can't install JFreechart

 
0
  #12
Jul 3rd, 2009
Originally Posted by di2daer View Post
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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 28
Reputation: anusha88 is an unknown quantity at this point 
Solved Threads: 0
anusha88 anusha88 is offline Offline
Light Poster

Re: can't install JFreechart

 
0
  #13
Jul 3rd, 2009
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?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC