| | |
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:
To compile Test.java & Launch Test class
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)
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
Java Syntax (Toggle Plain Text)
>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
Failure is not fatal, but failure to change might be. - John Wooden
•
•
Join Date: Jun 2009
Posts: 28
Reputation:
Solved Threads: 0
•
•
•
•
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
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.
•
•
Join Date: Jun 2009
Posts: 28
Reputation:
Solved Threads: 0
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?
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?
![]() |
Similar Threads
- install vmware-tools in redhat 9.0 /XFree86 (Window and Desktop Managers)
- How To install new fonts...??? (Windows NT / 2000 / XP)
- IE6 Install Complete (Web Browsers)
- grub or Lilo install (*nix Software)
- I Cant Install An Operating System! HELP! (Windows NT / 2000 / XP)
Other Threads in the Java Forum
- Previous Thread: url case sensitive
- Next Thread: Frame and Multiple Panel ..Need Help
| Thread Tools | Search this Thread |
2dgraphics account android api apple applet application arguments array arrays automation banking binary binarytree bluetooth chat chatprogramusingobjects class client code color component count database derby design eclipse eclipsedevelopment encryption error fractal game givemetehcodez graphics gridlayout gui homework html ide if_statement image integer interface j2me java javadesktopapplications javaprojects jlabel jni jpanel julia keyword linux list macintosh map method methods midlethttpconnection mobile netbeans newbie nullpointerexception object open-source os problem producer program programming project projectideas property read recursion reference replaysolutions ria scanner search server set size sms sort sourcelabs splash sql sqlite stop string swing testautomation threads transforms tree ui unicode validation windows






