Bootstrap FreeKB - Java - Add a JAR file to Java Build Path in Eclipse
Java - Add a JAR file to Java Build Path in Eclipse

Updated:   |  Java articles

Adding a JAR to the Java Build Path in Eclipse will allow you to use the JAR in Eclipse (eg. the app will be able to use the classes in the JAR). 

  1. Right-click on your project and select Properties.
  2. Select Java Build Paths.
  3. Select the Libraries tab.
  4. Select Add External JARs.
  5. Select the JAR and select Apply.

In this example. Sample.jar has been added to the Java Build Path.

 


If you want the JAR to be placed in your apps /WEB-INF/lib folder when the WAR is compiled, you'll want to add a Java Build Path Entry. In this way, when the WAR is deployed to your application server, such as JBoss, Tomcat, or WebSphere, the JAR will be in the /WEB-INF/lib directory of your app, and you app will be able to use the JAR.

  1. Select Deployment Assembly.
  2. Select Add, then select Java Build Path Entries and click Next.
  3. Select the JAR and select Finish.
  4. Select Apply.

Now, the JAR will contain "Publish/export dependency: /WEB-INF/lib.

 


Adding the JAR to the /WEB-INF/lib folder usually only makes sense when no other apps will be using the JAR. When two or more apps need to use the JAR, then you'll usually want to take a different approach.




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 6e6cc8 in the box below so that we can be sure you are a human.