| Author |
Between /lib and /web/WEB-INF/lib
|
andree surya
Greenhorn
Joined: Jun 13, 2009
Posts: 29
|
|
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
|
 |
Vijitha Kumara
Bartender
Joined: Mar 24, 2008
Posts: 3673
|
|
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).
|
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
|
 |
andree surya
Greenhorn
Joined: Jun 13, 2009
Posts: 29
|
|
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
Joined: Mar 24, 2008
Posts: 3673
|
|
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.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56549
|
|
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).
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26496
|
|
|
I keep mine in the WEB-INF/lib folder. I agree that it's a matter of personal preference.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
andree surya
Greenhorn
Joined: Jun 13, 2009
Posts: 29
|
|
|
Okay, I think I'll go with the /lib. Thanks for the input !
|
 |
skp Kumar
Greenhorn
Joined: Oct 11, 2009
Posts: 2
|
|
/lib : jar file available at server level
/web/WEB-INF/lib: jar files available at application level
|
 |
 |
|
|
subject: Between /lib and /web/WEB-INF/lib
|
|
|