31

I'm using Eclipse and I need to be able to add Java libraries (JAR files) into my web application's WEB-INF/lib folder. How do I achieve this?

metters
  • 533
  • 1
  • 8
  • 17
ferz
  • 493
  • 3
  • 10
  • 14

10 Answers10

47
  • Add the jar file to your WEB-INF/lib folder.
  • Right-click your project in Eclipse, and go to "Build Path > Configure Build Path"
  • Add the "Web App Libraries" library

This will ensure all WEB-INF/lib jars are included on the classpath.

Mike G
  • 4,713
  • 2
  • 28
  • 31
7

Found a solution. This problem happens, when you import a project.

The solution is simple

  1. Right click -> Properties
  2. Project Facets -> Check Dyanmic Web Module and Java Version
  3. Apply Setting.

Now you should see the web app libraries showing your jars added.

madhairsilence
  • 3,787
  • 2
  • 35
  • 76
  • 1
    omg this finally owkred for me, facet was 1.6 but build 1.7 :) – VeenarM Apr 19 '14 at 12:51
  • I tried this and it most definitely caused an issue. My META-INF > jdoconfig.xml file became full of "errors' which I am convinced are not real errors because the file is a complete replicate of it's head revision. Also, when I then unchecked Dynamic Web Module the problems did not go away. – miss.serena Jul 23 '14 at 21:12
3

Pasting the jar files in WebContent\WEB-INF\lib via the file system was the only way it worked for me.

They then appeared under the Deployed Resources and WebContent lib sub-folders.

When I looked, the build path had the jars in the Web App Libraries and everything built and ran fine.

G O'Rilla
  • 268
  • 3
  • 5
3
  1. add the jar to WEB-INF/lib from file structure
  2. refresh the project, you should see the jar now visible under the WEB-INF/lib folder.
Saurabh Saha
  • 962
  • 11
  • 18
2

add the jar to WEB-INF/lib from file structure refresh the project, you should see the jar now visible under the WEB-INF/lib folder.

this is the best solution that worked for me

Shaina Raza
  • 1,474
  • 17
  • 12
  • 1
    If all you wan is to put a jar in the classpath, Eclipse offers standard support as described in this rather old [stackoverflow question/answer](http://stackoverflow.com/questions/3280353/how-to-import-a-jar-in-eclipse) – MikeJRamsey56 Nov 05 '16 at 03:04
2

They are automatically added to the project classpath if its a web project. Sometimes it does not work properly, a refresh or close/open of the project helps.

if its not a web project you can right click on the library and go to "Build Path" -> "Add to Build Path"

morja
  • 8,297
  • 2
  • 39
  • 59
  • 1
    Yes, a requirement to this is that the "Web App Libraries" are added to the Build Path as MikeG wrote. – morja Dec 14 '10 at 15:07
1

Check under project properties -> deployment assembly if jar file are under deployed path- WEB-INF/lib if not use add button and add jar under WEB-INF/lib

sometime eclipse (in my case Juno Service Release 2 ) was not doing it for me so i did manually. this worked for me.

ifti
  • 649
  • 1
  • 11
  • 25
0

From the ToolBar to go Project> Properties>Java Build Path > Add External Jars. Locate the File on the local disk or web Directory and Click Open.

This will automatically add the required Jar files to the Library.

lennon310
  • 12,503
  • 11
  • 43
  • 61
Vikram Belde
  • 979
  • 8
  • 16
0

In case this helps anyone, if you are using a Git repo, make sure the jars make it into the WEB-INF/lib INSIDE the git repo and not just in the project WEB-INF/lib

0

Add the jar file to your WEB-INF/lib folder. Right-click your project in Eclipse, and go to "Build Path > Configure Build Path" Add the "Web App Libraries" library This will ensure all WEB-INF/lib jars are included on the classpath. helped me..

Drag and drop in WEB-INF/lib folder and restart eclipse ans start webservice then create client

Umesh Bhutada
  • 301
  • 2
  • 4