How do I Set the CLASSPATH Variable Using Linux?

Create a file called /etc/profile.d/jdk.sh and fill it with this:

  if [ -z "${JAVA_HOME}" ] ; then
    export JAVA_HOME=/usr/lib/jdk116
  fi
  if [ -z "${JDK_HOME}" ] ; then
    export JDK_HOME=/usr/lib/jdk116
  fi
  SW=`cat /etc/profile.d/java`
  SW=`echo ${SW}  | sed -e "s/ /:/g"`
  MYPATH="${JDK_HOME}/lib/classes.zip:${SW}"
  export CLASSPATH="${MYPATH}"
  MYPATH="${JDK_HOME}/bin/"
  echo ":${PATH}:"| grep "${MYPATH}" >/dev/null ||\
    PATH="${PATH}:${MYPATH}"

  export PATH
  unset SW MYPATH

Create a file called /etc/profile.d/javaM and fill it with a list of directories, jars, and zips.