How to Add JARs to Java Project Build Paths

Using Eclipse to Include Java Archives for Your Project

The Armchair Geek
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:

Open your project folder. Create a folder named "lib" in the project folder. Next, copy all the JARs that you will be using to your project to the "lib" file. 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
Expand the lib file in Eclipse and select all the JARs that you will be using. Next, right-click on the selected JARs and then click on: Build Path. Now select: Add to Build Path.
Once you do this, the JARs will disappear from lib and reappear in the "Referenced Libraries" section. And you are done!

Method #2
Right-click on the project name and then navigate to: Build Path. Next, select: Configure Build Path... The project properties window should appear showing your build path settings and configurations.
Select the Libraries tab and then click on: Add JARs... Now, 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. Click OK to close the properties window.

You should find that the JARs are now located in the References Libraries file instead of lib.

How to Add External JARs
To add external JARs, right-click on the project name and select: Build Path. Next, select: Add External Archives... Now locate and select the JARs that you want to add, and then click on: Open

The JARs will now appear in the Referenced Libraries file.

Published by The Armchair Geek

We are a Mid-West PLR Firm specializing in creating powerful web content for clients in a wide array of industries. This is a sampling of some of our IT-focused articles. For more of our work, you can co...  View profile

To comment, please sign in to your Yahoo! account, or sign up for a new account.