views:

19

answers:

1

Dear all

What difference between adding library by "add external jar" and putting those jars to web-inf\lib? What should I do for adding my external jars to my web dynamic project in eclipse Add by class-path or putting into web-inf\lib folder?

Regards

+1  A: 

When you add jar in the web-inf folder, they are packaged as part of your war file(assuming using some build tool like ant) and when your application is deployed or run it resolve dependencies using those jars.

But when you add jar in the eclipse using add external jar, it is just part of .classpath file for eclipse and resolve dependencies with in eclipse and doesn't get packaged. It can be used when you don't want some jar to be packaged with application like servlet jars which are already present in your server libraries.

Ankit
You mean I put jar files manually to the web-inf\lib bymyself?Is there any way to mark jar files when I add them by "add external jar" to package in lib folder automatically by eclipse?
Navid
There is an option in eclipse Java EE Module Dependencies, i think there you can specify jars you want to package. But once you use some build tool like ant for packaging and deploymeny, then you can need to figure out which all jars you want to publish and provide path to ant.
Ankit