java - How do I get started with JFreeChart? -
i've never used third party library before. should after downloaded jfreechart-1.0.14.tar.gz
?
i don't know if i'm doing these things right:
1. put jcommon-1.0.17.jar
, jfreechart-1.0.14.jar
@ same directory source code.
2. import needed class in source code (e.g. import org.jfree.util.rotation;
)
many articles tell how in ides. instead of ides, i'm writing codes vim , compile myself. so, assume didn't thing wrong, how should compile source code javac
, run code java
?
edit:
here's file layout:
./src
| - test.java
./lib
| - jcommon-1.0.17.jar
| - jfreechart-1.0.14.jar
i compile by
javac -cp "lib/*" -d classes/ src/test.java
run by
java -cp classes:lib/jcommon-1.0.17.jar:jfreechart-1.0.14.jar test
however, error occurs:
exception in thread "main" java.lang.noclassdeffounderror: org/jfree/data/general/piedataset
how can resolve problem?
exception in thread "main" java.lang.noclassdeffounderror: org/jfree/data/general/piedataset @ java.lang.class.getdeclaredmethods0(native method) @ java.lang.class.privategetdeclaredmethods(unknown source) @ java.lang.class.getmethod0(unknown source) @ java.lang.class.getmethod(unknown source) @ sun.launcher.launcherhelper.getmainmethod(unknown source) @ sun.launcher.launcherhelper.checkandloadmain(unknown source) caused by: java.lang.classnotfoundexception: org.jfree.data.general.piedataset @ java.net.urlclassloader$1.run(unknown source) @ java.net.urlclassloader$1.run(unknown source) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(unknown source) @ java.lang.classloader.loadclass(unknown source) @ sun.misc.launcher$appclassloader.loadclass(unknown source) @ java.lang.classloader.loadclass(unknown source) ... 6 more
the libraries shouldn't @ same place source code. if don't want use build tool gradle yet, handle library dependencies, suggest using following layout:
project src .java files here, organized in folder tree matching package tree classes compiled .class files here lib .jar files here
to compile, go in project directory , execute following command:
javac -cp lib/jfreechart-1.0.14.jar:lib/jcommon-1.0.17.jar -d classes src/com/foo/bar/myclass.java src/com/foo/bar/myotherclass.java
to run app, execute following command:
java -cp classes:lib/jfreechart-1.0.14.jar:lib/jcommon-1.0.17.jar com.foo.bar.myclass
Comments
Post a Comment