Re: Java libraries and proposal.
> On Sat, Apr 07, 2001 at 07:47:29PM -0700, Per Bothner wrote:
> > I disagree. My goal is that that /usr/share/java (or
> > /usr/share/java/lib if you prefer) should be similar to Sun's
> > extensions directory: a directory where *all* .jars
> > (i.e. /usr/share/java/*.jar) are added to the implied classpath.
> > (This is of course a default assuming nothing is over-ridden.) Yes,
> > you could define a standard where all .jars in all subdirectories of
> > /usr/share/java (i.e. /usr/share/java/*/*.jar) but I think that is
> > going too far.
> I think explicitly specifying the .jars you want to import into your
> library or application, with sonames if necessary, seems better. The
> 'add everything' approach only invites DLL hell.
Personally, I like the idea of /usr/share/java/*.jar. I'd take it a step
You see, I jump between projects a lot (I just "cd" between their
directories), and I often need different sets of .jars for each one. I could
try to maintain a set of scripts that set my classpath for the appropriate
project, but that's kind of a pain because:
1 - I have to remember to take it with me if I move development to another
2 - I have to either "source" the script if it sets the env directly (ie, "
. ./setclasspathforprojectX") or "eval" it if the script merely prints out
the appropriate line to set the classpath.
3 - Moving the files into production (say, on Tomcat), will often break the
app because the app-server doesn't use my script to set the classpath.
To this end, the following is a description of how my dream java invoker
would build the classpath:
1 - Start with the classpath needed to for this particular JVM/compiler
2 - Append contents of the CLASSPATH env variable.
3 - If the directory "./lib" exists, append all files matching
"./lib/*.jar" to the classpath.
4 - If the directory "./classes" exists, append that to the classpath.
5 - If the directory "$HOME/lib" exists, append all files matching
"$HOME/lib/*.jar" to the classpath. If you want to use a different directory
than $HOME, you can specify that directory in, say, JAVALIBDIR, so that it
would look for "$JAVALIBDIR/lib" instead.
6 - If the directory "$HOME/classes" exists, append it to the classpath
(with same provision for using $JAVALIBDIR instead of $HOME).
7 - Append all files matching "/usr/share/java/lib/*.jar" and the directory
"/usr/share/java/classes" to the classpath.
The nice things about this are that:
1 - Any user can override existing classes in /usr/share/java or specify
additional classes for all of his/her own projects (by using $HOME/lib and
2 - Any user can do the same on a *per-project* basis (by using ./lib and
3 - If you try to keep all of the jars/classes (or links to them) that a
particular app needs in your project-wide lib dirs (the "./lib" and
".classes"), then you can just copy the whole tree right into, say, Tomcat's
webapps tree and it should work right off. No having to hunt down all of the
jars/classes that you've got all over the place.