Search code examples
compilationclasspathjavajgrapht

How do I add the jgrapht library to my system?


This is probably a silly question, but how or where do I add jgrapht so my java compiler in terminal will include it? I've got the .jar file but don't know where to put it.

I'm using Mac OS X ML and Netbeans.


Solution

  • To use an external Java library you need to add it to your classpath. The Java documentation has some great information on how to set it.

    Assuming you're using the javac compiler, you'll use a command similar to:

    javac -classpath path to jgrapht jar file ... other options and files here ...

    See also: Compiling Java

    You specifiacally mention Netbeans, so you'll also want to look at this question, and this blog post.

    I hope this helps! :)