jeff wrote:


> Why not just put the jars in /usr/share/java, keep the system classpath
> completely clean, and let the startup scripts for individual apps choose which
> to include?


IMHO that's the best thing to do. Each packaged application knows which classes
it depends on and can include them into the local classpath in the startup
script. This can even be made configurable by the local administrator using
/usr/share/<package>/lib/*.jar as classpath. I'm using this e.g. in Ant:

 > less /usr/bin/ant
#!/bin/sh

# Add all JAR files in /usr/share/ant/lib/ to CLASSPATH
LOCALCLASSPATH=`echo /usr/share/ant/lib/*.jar | tr ' ' ':'`

if [ "$CLASSPATH" != "" ] ; then
   CLASSPATH=$CLASSPATH:$LOCALCLASSPATH
else
   CLASSPATH=$LOCALCLASSPATH
fi


If you want Ant to include any other jars, just copy or even better
symlink them to /usr/share/ant/lib. My postinst creates some initial
symlinks based on the already installed packages:

for jar in antlr bsf junit jython log4j oro regexp xalan2 xalanj1compat xerces; do
   if [ -f /usr/share/java/${jar}.jar -a ! -e /usr/share/ant/lib/${jar}.jar ]; then
     ln -s ../../java/${jar}.jar /usr/share/ant/lib/${jar}.jar
   fi
done

Please note that I'm deliberatly ignoring /usr/share/java/repository, some
JRE/JDK startup scripts (/usr/bin/java) include in in the classpath, though.

I know that these suggestions only solve to the problem for applications
but not for Java developers. But I think they should decide which classes are
in their classpath and we should *never* automatically include all installed
JARs in the classpath. There might be incompatible JARs (maybe xalan and
xalanj1compat?) in /usr/share/java/ or duplicate classes if we use symlinks
to a versioned JARs.

What about a directory /etc/java/default-classpath/ that contains symlinks like
/usr/share/ant/lib/ above? All there classes could be put in the classpath
by /usr/bin/java *if* *$CLASSPATH* *is* *empty*? Of course, the core classes
(rt.jar or classes.zip for JDK1.1) should always we included if they are
not already in the classpath. $JAVA_HOME/lib/ext/ can then be used for classes
specific to a JVM.

-- 
Stefan Gybas



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to