How to Add JAR Libraries to Eclipse Project Build Paths

When your Java project requires JAR libraries to function, you have to configure your project to include the libraries in its build path. Fortunately, Eclipse makes this process simple and easy to remember. The build used here is Eclipse Ganymede 3.4.0.

[edit] Steps

Adding Internal JARs

  1. Copy the JARs you'll be using to your project if you haven't done so already. Here's how it's conventionally done:

    1. Create a new folder named lib in your project folder. This stands for "libraries" and will contain all the JARs you'll be using for that project.
    2. Copy the JARs you need to lib.
    3. Copied JARs to the project.
      Copied JARs to the project.
      Refresh your project by right clicking the project name and selecting Refresh. The lib folder will now be visible in Eclipse with the JARs inside.
  2. Complete either of the following to finish configuring your build path.

Method 1

  1. Expand lib in Eclipse and select all the JARs you need.
  2. Right click the JARs and navigate to Build Path.
  3. Select Add to Build Path. The JARs will disappear from lib and reappear in Referenced Libraries.

Method 2

  1. Right click the project name and navigate to Build Path.
  2. Select Configure Build Path... and the project properties window will appear showing your build path configurations.
  3. Select the Libraries tab.
  4. Click Add JARs...
  5. Locate and select the JARs you want and click OK. The JARs will now appear in the list of libraries in the build path.
  6. Click OK to close the properties window. The JARs will now be in Referenced Libraries instead of lib.

Adding External JARs

  1. Complete either of the following; both results will be the same.

Method 1

  1. Right click the project name and navigate to Build Path.
  2. Select Add External Archives...

  3. Locate and select the JARs you want and click Open. The JARs will now appear in Referenced Libraries.

Method 2

  1. Right click the project name and navigate to Build Path.
  2. Select Configure Build Path... and the project properties window will appear showing your build path configurations.
  3. Select the Libraries tab.
  4. Click Add External JARs...
  5. Locate and select the JARs you want and click Open. The JARs will now appear in the list of libraries in the build path.
  6. Click OK to close the properties window. The JARs will now be in Referenced Libraries.


[edit] Tips

  • Whenever you add new files or folders to your projects in Eclipse via anything but Eclipse, you must refresh the affected projects to let Eclipse know that the new files are there. Otherwise you may run into compiler or build path errors.
  • Though the internal JARs disappear from lib, they are still there in the file system. It is merely Eclipse's perspective telling you that those JARs have been added.


Embed this: Republish this entire article on your blog or website.

Was this article accurate? Yes No

Edit This Page E-mail this to a Friend Printable version
Discuss This Page Thank the Authors Write an Article
Categories:Programming | File Manipulation

Authors

Andy C Zhang, VC
Thanks to all authors for creating a page that has been read 3,623 times.

Related wikiHows

Hide These Ads - Why?


Hide These Ads - Why?
Show Ads

Navigation

Editing Tools

My Pages