Question

I'm trying to use an open source java library to visualize nodes and edges in a graph, but I'm completely lost.

I have a bunch of jar files in a folder. Clicking on some of the jar files makes java swing windows pop open with graphs displayed. Clicking other jar files does nothing.

If I figured that out, would I just stick the jar files in there with the other ones, or would that still not work?

And if I ever figure out how to use these files, does that mean that I have to include them if I transfer my java project to another computer? How would I go about doing that?

Was it helpful?

Solution

Have you included those libraries in your classpath?

If you are using eclipse, you could

Project - > properties -> Java build path ->addJar.

And the Jar file should be placed in a directory inside your workspace (lib/ for example)

If you have to take your project to another computer, you could take these steps

  1. Before doing anything, export your project (as a Jar file, for example).
  2. Save it into your favorite drive (cd / usb drive/ diskette/ tape).
  3. On "the other" computer, you can import this project into your workspace

OTHER TIPS

I believe if you put the jars in your classpath, you can import and use classes just like you would a standard library. Figuring out the classpath can be confusing, but you can just set it when you start your jvm. Your IDE may have options for it, too.

Most java problems are classpath problems.

In Eclipse, you need to add libraries to the project build path.

In general, you need to provide dependencies via the classpath mechanisms at compile time and runtime. The precise mechanisms vary, but, for example, if you used the javac compiler, you would provide your libraries on the command line:

javac -classpath C:\dir\lib1.jar;C:\dir\lib2.jar foo/MyClass.java

These dependencies would also be required to invoke the app:

java -classpath C:\dir\lib1.jar;C:\dir\lib2.jar;. foo.MyClass

This page gives some good info, though googling for the term "classpath" should provide alternative sources.

You use it by including it in the classpath of your java application, that way you can reference it from your code. Here is a starter document. The JDK 1.6 has some easier options (such as specifying multiple jar files as *.jar). It is definitely a little complicated, but it is very worth knowing.

You should have documentation for these Jars. Some sounds like examples, but one must be the core graph modelling and rendering Jar. Hopefully the examples have source included.

Just add that Jar to your project in Eclipse (e.g., in a /lib folder in your project, then add it to the build path) and use the documentation to use the code. You can also use Eclipse to look inside the Jar file.

Unless there is no alternative, it probably isn't worth using a load of third party code that isn't documented at least on the API level, and without any source examples definitely not.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top