Question: How can I set my shell environment to use us a specific JDK?

Shared Hosting

Edit (or create) in your home directory .bash_profile and copy the following into it. The below example uses JDK 1.7 as an example. Simply change the version number to suite your needs.

export JAVA_HOME=/usr/local/jdk1.7-latest
unset CLASSPATH
for i in ${JAVA_HOME}/lib/*.jar ; do
  if [ "$CLASSPATH" != "" ]; then
    CLASSPATH=${CLASSPATH}:$i
  else
    CLASSPATH=$i
  fi
done
export CLASSPATH=/usr/local/jdk1.7-latest/lib:${CLASSPATH}
export PATH=$JAVA_HOME/bin:$PATH


CategoryJava

Java/how-can-i-set-my-shell-environment-to-a-specific-jdk (last edited 2015-08-24 12:28:28 by wilhelms)