Meaningless Drivel is fun!*
The moose likes Servlets and the fly likes about development with multiple java packages using ant Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "about development with multiple java packages using ant" Watch "about development with multiple java packages using ant" New topic
Author

about development with multiple java packages using ant

david hu
Ranch Hand

Joined: Jul 20, 2001
Posts: 143
Hi,

I am working on a project that used multiple open source java packages in addition to J2EE. My question is that

1) where do you guys put these jars files, in the ..\lib directory where these packages installed? or put them into a single location?

2) During deployment, do you put all these jars files inside tomcat_home\shared\lib, or just set the classpath to where thse ..lib directory where these packages installed?

3) How to make ant build easier for the build and deployment process?

Thanks,

David
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

At run-time, I place them in WEB-INF/lib because different web applications may require different versions of the packages.

At compile it doesn't really matter where you put them as long as you define your ant task to add them to the classpath.

I keep them in a single location where ant adds them to the classpath, then makes a copy in WEB-INF/lib when building the war file.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

I agree with Bear on most points. (I've stopped being surprised at this )

Yes, always try to place the jars in the WEB-INF/lib directory. There are some specific cases I've found it necessary to place them elsewhere, but they are the exception to the rule (such as using LDAP for authentication, since the server needs the jars too)

I tend to try to do it the way Bear says at compile time, and this is a good way to do it, although when I'm feeling lazy I place the runtime jars in the WEB-INF/lib dir and the compiletime or testing JARs (such as junit or j2ee jars) in a lib jar.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61092
    
  66

Originally posted by David O'Meara:
There are some specific cases I've found it necessary to place them elsewhere...


Another good example of this is when using container-managed connection pooling. The jar file with the JDBC implementation must be placed in common/lib so that it available to both Tomcat and the web apps.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: about development with multiple java packages using ant