Search code examples
javajarwindows-8classpath

How to add a JAR library withou an IDE?


I'm facing difficulties on adding a JFreeChart library on my Java project (I use Windows 8). This is what I've already done:

1 - Unzipped JFreeChart

2 - renamed the archive jfreechart - 1.0.19 to jfreechart

3 - Added it's path to classpath: .;C:\Users\Victor\Desktop\projects\EP2 - IA\jfreechart - 1.0.19\lib\jfreechart.jar;

4 - Added in the beggining of my Java file: import jfreechart.*;

5 - Copied the jfreechart archive to the same directory of my project

But when I try:

java -classpath jfreechart.jar MyClass.java

it returns that the "jfreechart package does not exists"

As I'm an old school programmer that still uses Notepad, I've found nothing useful on Google about it.


Solution

  • You are using the wrong import statement. Try this instead:

    import org.jfree.*;
    

    You also may need the following library:

    jcommon-1.x.y.jar
    

    For future reference, you can view the contents of a JAR file using the command line jar command:

    jar -tvf jfreechart-1.0.19.jar