How to add a JAR library to a Java project without IDE?

Asked

Viewed 842 times

2

Save. I’m having trouble adding the Jfreechart library to my Java project (using Windows 8). I’ve unpacked Jfreechart, but I don’t know what to do from there. Since I’m an old school programmer and still use Notepad, I couldn’t find anything on Google that would help me.

Thank you very much.

  • If you still need help, please edit your question and add the class code, the exact error message, the executed commands and in which directory it was executed, and finally the places where the files are (class, jar, etc.). Hug!

  • Thank you very much man! But I think I’ve already solved this problem (I just can’t remember how). Hugs!

2 answers

2

You must have forgotten an addiction, specifically:
jcommon-1.0.23.jar
(rev. 1.0.23 may vary, this comes with the latest release of Jfreechar)

You find the dependency information on download page of Jfreechart:

Jcommon Dependency Jfreechart requires the Jcommon class library. The Jcommon Runtime jar file is included in the Jfreechart download --- if you require the source code for Jcommon (Recommended), you need to download this separately.


javac -classpath jfreechart.jar;jcommon-1.0.23 CompileMe.java


I recommend using some Java IDE to make your job easier.

1

You need to pass the classpath when executing the javac

javac -classpath jfreechart.jar minhaClasse.java
  • He says the package doesn’t exist : /

  • they are in the same folder?

  • what error displays?

  • Yes, they are. He says that the "package jfreechart does not exist" (just to check:the name of this jar also had the version of the same, which I removed). I’ve already added the path to the jar on the classpath, but nothing solves : /

  • your class is with package?

  • No. Only with import jfreechart. *; which I put at the beginning and the class itself. I don’t know if it’s useful information, but I just copied the JAR to the directory with the class.

  • Try javac -cp ".;jfreechart.jar" minhaClasse.java

  • Still nothing. However, I noticed something: if I remove Import, the class compiles with the command that is in the answer. Here is my question: using this command, does import still need? Or when I compile it like this I "already automatically import"?

Show 3 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.