• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Between /lib and /web/WEB-INF/lib

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

I've been learning java web for several weeks and I always use "/web/WEB-INF/lib" as my compile classpath. Well, I don't feel right doing this, because I think that's not how "/web" directory supposed to be used. Recently, I see an example on the Internet that uses "/lib" (directly under root) as its compile classpath. However, if I do put my library (e.g. JDBC driver) under "/lib", still I have to put that library under "/web/WEB-INF/lib" for runtime usage, so the file will be redundant.

So basically my question is, where should I put external libraries?

Thanks,
Ang
 
Bartender
Posts: 4101
63
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

andree surya wrote:... So basically my question is, where should I put external libraries?


I'm not sure your are talking about building with IDE or in general. But people use different approaches in this, specially building with Ant etc.. In this case If you have put the "jars" inside the WEB-INF/lib then you can point them to the compiler too, so you don't have to have duplicates. If you are talking about any IDE like "Eclipse" then you may have some common "user libraries" setup to use in each project (which can be used config the build path).

 
andree surya
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Currently I'm working without IDE, and I configure the classpath manually inside the ant build file.
I set my compile classpath by including every jar files inside /web/WEB-INF/lib. So it's okay and common to do this? I don't need to create a separate /lib directory?
 
Vijitha Kumara
Bartender
Posts: 4101
63
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

andree surya wrote:... I don't need to create a separate /lib directory?


No. Tools like "Maven" have addressed these issues in depth by having a repository for all the artifacts locally.
 
Marshal
Posts: 67280
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An overly-complex tool like Maven is hardly necessary.

For the purpose of compilation, you can have the jar files anywhere you'd like as long as they are part of the compilation classpath.

Personally, I do put them in a /lib folder for compilation, and have the ant build copy them into WEB-INF/lib when it assembling the web application for deployment (or creation of a war file).
 
author & internet detective
Posts: 39448
768
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I keep mine in the WEB-INF/lib folder. I agree that it's a matter of personal preference.
 
andree surya
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, I think I'll go with the /lib. Thanks for the input !
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
/lib : jar file available at server level
/web/WEB-INF/lib: jar files available at application level
 
He was expelled for perverse baking experiments. This tiny ad is a model student:
create, convert, edit or print DOC and DOCX in Java
https://products.aspose.com/words/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!