Man Chi Ly wrote:
chances are a Linux newbie is using bash (default on GNU/Linux) :) The
short answer is CLASSPATH is pretty much deprecated in JDK 1.2 (the
JDK README briefly discusses this). And I'm pretty sure a more lengthy
discussion can be found on java.sun.com. This question is a FAQ, and with
sketchy details ("can't import any classes"), doesn't really belong on
this mailing list?


There are more interesting uses of the classpath, than importing system classes.
For instance, the classpath allows you to construct a class repository, without having to cross link all
the jar or class files to the jre/lib directory every time you upgrade you jdk version

For instance, I am using an /opt/java/repository directory for my class repository and have something
like the following in the user login scripts (in profile.d directory):

<script>
#! /bin/sh

JAVA_TOPDIR=/opt/java

# Set the CLASSPATH
JAVA_REPOSITORY=${JAVA_TOPDIR}/repository
CLASSPATH=${JAVA_REPOSITORY}/classes

# add jar files
for i in ${JAVA_REPOSITORY}/jar/*.jar
do
        CLASSPATH=${CLASSPATH}:${i}
done

for i in ${JAVA_REPOSITORY}/jar/*.zip
do
        CLASSPATH=${CLASSPATH}:${i}
done

# Add the current dir to the path
CLASSPATH=$CLASSPATH:.

# Check jdk version
if [ -f $JAVA_TOPDIR/JAVA2 ];
then
        JDK_HOME=$JAVA_TOPDIR/jdk
        JIKES_CP=$JDK_HOME/jre/lib/rt.jar:$CLASSPATH
        #export JAVA_COMPILER=tya
else
        JDK_HOME=$JAVA_TOPDIR/ibmjdk
        CLASSPATH=${CLASSPATH}:${JAVA_TOPDIR}/jdk.x/swing/swingall.jar
        JIKES_CP=$JDK_HOME/lib/classes.zip:$CLASSPATH
        if [ -n "$JAVA_COMPILER" ]; then
                unset JAVA_COMPILER
        fi
fi

PATH=$JDK_HOME/bin:$PATH

# native libraries repository
JNI_REPOSITORY=${JAVA_REPOSITORY}/native

export PATH CLASSPATH JAVA_TOPDIR JAVA_REPOSITORY JDK_HOME JIKES_CP JNI_REPOSITO
RY
</script>
 

As you can notice, this script allows instant change between jdk versions - rm the JAVA2 marker and
you are back to ibm jdk!

-- dimitris 
   mailto:[EMAIL PROTECTED]
 


Reply via email to