Add a JAR to Java Build Path in Eclipse

Home > Search
  by

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.



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




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




Comments