Adding 3rd party jars to WEB-INF/lib automatically using Eclipse/Tomcat

JavaEclipseTomcatJarBuildpath

Java Problem Overview


I have a dynamic-web project set up on Eclipse and I'm using Tomcat 7 as my web server. It doesn't seem to be automatically putting 3rd party JARs I add to my library on my build path into the WEB-INF/lib folder. Is there a way I can do this automatically? Every time I search for an answer to this, I find something like https://stackoverflow.com/questions/2890183/including-java-libraries-to-tomcat-inside-eclipse">this</a>;.

So how do I do that automatically? Is there a way to configure my build path to do this?

Java Solutions


Solution 1 - Java

Here are the instructions for Helios. For earlier releases, see SeanA's answer.

  1. Project Properties -> Deployment Assembly
  2. Add -> Java Build Path Entries
  3. You should now see the list of libraries on your build path that you can specify for inclusion into your finished WAR.
  4. Select the ones you want and hit Finish.

Solution 2 - Java

You can use "Ant" to copy files to WEB-INF/lib when you deploy files. Using Ant you will be able to copy only those files which have changed.

http://ant.apache.org/manual/Tasks/copy.html

http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.platform.doc.user/gettingStarted/qs-81_basics.htm

Solution 3 - Java

I haven't tried this personally, but what I believe it does is what I think you are looking for:

  • Right-click project -> Properties
  • Go to Java EE Module Dependencies
  • Check the boxes for the JARs that you want to export with your Web Application

Let me know if this automatically puts them in your exported WAR. I always just add mine to WEB-INF/lib :)

Solution 4 - Java

Instructios for Eclipse Indigo (version 3.7.2)

  • Project Properties -> Deployment Assembly
  • Add -> Archives From File System -> Next -> Add
  • (The file dialog of your system opens up.)
  • Navigate to the archive you want to include in your WEB-INF/lib, select it and hit OK.
  • Hit Finish.
  • Hit OK.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDaveView Question on Stackoverflow
Solution 1 - JavaKonstantin KomissarchikView Answer on Stackoverflow
Solution 2 - Javakensen johnView Answer on Stackoverflow
Solution 3 - JavaSean AdkinsonView Answer on Stackoverflow
Solution 4 - Javauser130506View Answer on Stackoverflow