Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add all external jars to library on eclipse export to war

Now that i've been doing some research I understand that I need to be placing my dependent external jars in the web-inf/lib folder for a dynamic web project in eclipse. Unfortunately until now I have simply been importing them in on the build path within eclipse and then again in the runtime config for my testing server.

Is there a simple way to copy all of the dependent jars to the web-inf/lib folder upon export or do I have to manually find each one, and place it in the folder? Is there a better way to manage external jars during development so I don't have to be concerned with importing them to the build path, and then the runtime, and then the library folder? I've tried using Project >> Properties >> Java Build Path >> Order and Export and checking all the jars, but they still don't seem to export with the war.

I am using tomcat as my production server and figured all of this out when I couldn't start the project due to defclassnotfounderror's in the log file.

like image 972
ryandlf Avatar asked Aug 12 '12 01:08

ryandlf


1 Answers

Right Click on the project -> properties. On properties window

  1. select "Deployment Assembly" on the left hand side
  2. Click "add"
  3. select "Java Build Path Entries".
  4. Select all the required libraries

Right Click on the project -> export. Select Web -> .war file.
You will find the libraries under /WEB-INF/lib

like image 200
Sanjay Avatar answered Oct 18 '22 02:10

Sanjay