Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you use a Java Library?

Tags:

java

jar

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?

like image 905
J.R. Avatar asked May 05 '09 15:05

J.R.


People also ask

What is Java library example?

Java is one of the most popular programming languages. Java provides a rich set of libraries, and its standard Java library is a very powerful that contains libraries such as java. lang, java. util, and java.

How are Java libraries used in processing?

To use a library class, you have to do two things: first you have to add the library to your sketch (which you do via the Contributions Manager or by dragging a . jar file onto the Processing editor), and second you have to import the classes from their packages.

Why do we need Java libraries?

Java has been a top-ranked programming language for years, thanks in part to an enormous set of libraries—both bundled with the software and available free in open source repositories—that developers can assemble to perform just about any task.


2 Answers

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
like image 187
Tom Avatar answered Oct 05 '22 16:10

Tom


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.

like image 44
Jonathan Adelson Avatar answered Oct 05 '22 18:10

Jonathan Adelson