PDF download Download Article PDF download Download Article

When your Java project requires JAR libraries (Java Archive) 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 Java - Ganymede 3.4.0.

Part 1
Part 1 of 5:

Adding Internal JARs

PDF download Download Article
  1. This stands for "libraries" and will contain all the JARs you'll be using for that project.
  2. Select the JAR files you need and right-click them. Select them and click copy. Then paste them into the lib folder by clicking File then Paste or using Control or Command V.
    Advertisement
  3. Do this by right-clicking the project name and selecting Refresh. The lib folder will now be visible in Eclipse with the JARs inside.
  4. Advertisement
Part 2
Part 2 of 5:

Configuring Your Build Path

PDF download Download Article
  1. Click the arrow to the left of the folder to expand it.
  2. Hold ⇧ Shift and click the JARs in the expanded folder.
  3. This opens a pop-up menu to the right.
  4. Placing the mouse cursor over "Build Path" displays a submenu to the left.
  5. The JARs will disappear from lib and reappear in Referenced Libraries .
  6. Advertisement
Part 3
Part 3 of 5:

Configuring Your Build Path (Alternative Method)

PDF download Download Article
  1. This displays a pop-up menu to the right.
  2. It's in the pop-up menu that displays when you right-click on the project name. This displays a sub-menu to the right.
  3. The project properties window will appear showing your build path configurations.
  4. It's at the top of the project properties window.
  5. It's on the right side of the project properties window.
  6. The JARs will now appear in the list of libraries in the build path.
  7. The JARs will now be in Referenced Libraries instead of lib .
  8. Advertisement
Part 4
Part 4 of 5:

Adding External JARs

PDF download Download Article
  1. This displays a pop-up menu to the right.
    • Note: It is much better to reference JARs that exist in your project or in other projects - this allows you to check in all of your dependencies to your version control system.
  2. This displays a sub-menu to the right.
  3. The project properties window will appear showing your build path configurations.
  4. It's to the right of the project properties window.
  5. It's at the bottom of the New Variables window.
  6. It's at the bottom of the preferences window.
  7. For example, if these are JARs for Tomcat, perhaps you could call it "TOMCAT_JARS".
  8. Click the Folder button and browse to the directory that contains the JAR path.
    • You can also Click File and select a specific jar file for the variable, if you prefer.
  9. This defines the variables.
  10. This closes the preferences dialog.
  11. Click the variable to select it.
  12. It's the button to the right of the list of variables.
  13. Click to select the JARs. Hold ⇧ Shift to select multiple JARs.
  14. This closes the extend dialog window.
  15. This closes the new classpath variable dialog.
  16. This closes the build path setup dialog.
    • If you share the project with someone else, they must also define the variable. They can define it under Window -> Preferences -> Java -> Build Path -> Classpath Variables .
  17. Advertisement

Adding External JARs (Alternative Method 1)

  1. This displays a pop-up menu to the side.
    • Note: If you use this method, the external JAR will need to be in the same location on the hard drive for anyone who uses this project. This can make sharing a common project more difficult.
  2. This displays a sub-menu to the right.
  3. It's in the Build Path sub-menu.

  4. The JARs will now appear in Referenced Libraries .
  5. Advertisement
Part 5
Part 5 of 5:

Adding External JARs (Alternative Method 2)

PDF download Download Article
  1. This displays a pop-up menu to the right.
    • Note: If you use this method, the external JAR will need to be in the same location on the hard drive for anyone who uses this project. This can make sharing a common project more difficult.
  2. It's in the pop-up menu that appears when you right-click the project name.
  3. The project properties window will appear showing your build path configurations.
  4. It's at the top of the project properties window.
  5. It's on the right side of the project properties window.
  6. The JARs will now appear in the list of libraries in the build path.
  7. The JARs will now be in Referenced Libraries .
  8. Advertisement


Expert Q&A

Ask a Question
      Advertisement

      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.
      • To be safe, you might want to create a folder in order to document your code. Here's how to do it:
        • Right-click the .JAR in the Reference Libraries in the package explorer.
        • Select the Javadoc tab and type in the folder (or URL) where the documentation is located. (Note: Eclipse will not like this and validation will fail. But don't worry, it will still work.)
        • Select Java Source Attachment and find the folder or .JAR file containing sources.
      Submit a Tip
      All tip submissions are carefully reviewed before being published
      Thanks for submitting a tip for review!
      Advertisement

      About This Article

      Article Summary X

      1. Create a new path called lib in your project folder.
      2. Copy and paste your JARs into the lib folder and refresh.
      3. Select all the JARs in the lib folder.
      4. Right-click the selected JARs in the lib folder.
      5. Select Build Path in the menu.
      6. Click Add to Build Path .

      Did this summary help you?
      Thanks to all authors for creating a page that has been read 1,326,089 times.

      Is this article up to date?

      Advertisement