javamavenjungjung2

Building JUNG library with Maven


I'm new to Java and I want to build the JUNG 2.2 library using Maven, because this seems to be the standard way to build it. I've never used Maven before but it was not difficult to install and running mvn clean install worked without a problem.

Now, JUNG appears to have 6 sub-packages (API, Implementations, Algorithms, I/O, Visualization and Samples), each one with its directory (e.g. jung-api is the directory for the API package). The install target produces some Java .class files and puts them in the target/classes/ directory of each of the 6 directories.

I am puzzled with what to do next in order to use the library: do I just need to add the jung directory path to my CLASSPATH variable in the shell? but then I would have to import jung-api.target.classes.edu.uci.ics.jung.graph.* which is not only extremely long to type but also has a “-”, which the Java compiler doesn't want in a package's name! And even when I bypass the “-“ problem I get a runtime error:

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Supplier

I'm using javac 1.8.o_91 on OS X 10.9.5.


Solution

  • The solution I found was to jar -xf each one of the .jar files in the jung-samples directory, and then move all the directories extracted by jar in a place which I added to my CLASSPATH variable. At least this seems to work.