How to Add JARs to Java Project Build Paths

Using Eclipse to Include Java ARchives for Your Project

Apr 9, 2009 Dianna Monda

Learn how to use Eclipse Ganymede to add Java ARchives (JARs) to your Java project build paths.

If your Java project needs Java ARchive (JARs) libraries to work properly, you will need to configure your project to include the libraries in its build path. Eclipse Ganymede (Java) makes this an easy, simple process. Read on to learn the different methods for adding JARs to project build paths using Eclipse Ganymede 3.4.0. This Ubuntu tutorial will show you how to add both Internal and External JARs to Java project build paths.

First, Create a Folder for Your JARs

Whichever method you will be using, as outlined below, you will first need to create a folder specifically for your JARs. This will act as your “libraries” file and will contain copies of all the JARs you will be using for the project. Here’s how to create the folder for your JARs:

  1. Open your project folder. Create a folder named “lib” in the project folder.
  2. Copy all the JARs that you will be using to your project to the “lib” file.
  3. Refresh your project by right clicking on the project name and selecting Refresh.

The lib folder should now be visible in Eclipse along with all the JARs inside.

How to Add JARs to Java Project Build Paths

After creating this folder and copying the JARs, you will now be able to configure your build path. Use one of the methods outlined below to do this.

How to Add Internal JARs

Method #1

  1. Expand the lib file in Eclipse and select all the JARs that you will be using.
  2. Right-click on the selected JARs and then click on: Build Path.
  3. Next, select: Add to Build Path.

Now the JARs will disappear from lib and reappear in the "Referenced Libraries" section. And you are done!

Method #2

  1. Right-click on the project name and then navigate to: Build Path.
  2. Next, select: Configure Build Path… The project properties window should appear showing your build path settings and configurations.
  3. Select the Libraries tab and then click on: Add JARs…
  4. Locate the JARs that you want to use and select them. Next, click OK. Now, the JARs will then appear in the list of the libraries in the build path.
  5. Click OK to close the properties window.
  6. You should find that the JARs are now located in the References Libraries file instead of lib.

How to Add External JARs

  1. To add external JARs, right-click on the project name and select: Build Path.
  2. Select: Add External Archives…
  3. Next, locate and select the JARs that you want to add.
  4. Now, click on: Open

The JARs will now appear in the Referenced Libraries file.

The copyright of the article How to Add JARs to Java Project Build Paths in Computer Software is owned by Dianna Monda. Permission to republish How to Add JARs to Java Project Build Paths in print or online must be granted by the author in writing.
Add JARs to Project Build Paths , Ubuntu/Debian Add JARs to Project Build Paths
   
What do you think about this article?

NOTE: Because you are not a Suite101 member, your comment will be moderated before it is viewable.
post your comment
What is 2+1?


Related Topics

Reference