0

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.

Giorgio
  • 2,137
  • 3
  • 20
  • 40
  • The `mvn clean install` should install the JARs in your local Maven repo. In any case (also when you just do `mvn clean package`), the `target` directory should contain the JARs. If there are *no* JARs, then likely something went wrong with the build. (If so: Are there any error messages hidden in the Maven output?). In any case, it should **NOT** be necessary to manually fiddle together JARs with `jar -xf` or so... – Marco13 Jul 29 '16 at 10:45
  • I hope you will excuse me but I don't even know where to locate my local Maven repository. Or maybe it's the new `.m2` directory in my home (which contains the same JARs and some other stuff). – Giorgio Jul 29 '16 at 11:16
  • Yes, that's it. ALL dependencies that are required by ANY library that is compiled with Maven will be copied there. And basically, `mvn clean package` only builds your JAR locally (into the `target` folder), whereas `mvn clean install` copies your newly built JAR into your Maven repo. – Marco13 Jul 29 '16 at 20:47

1 Answers1

0

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.

Giorgio
  • 2,137
  • 3
  • 20
  • 40