Configure A Tomcat Instance to Use A Specific Version of the JDK
Objectives
Prerequisites
Instructions
1. Log into the tomcat server via ssh.
2. Find the directory that contains the version of the JDK that you would like to use:
# ls -C1
/usr/java
#
JDK_DIRECTORY="/usr/java/jdk1.7.0_79"
# echo ${JDK_DIRECTORY}
3. Find the directory for the Tomcat instance that you would like to use a specific version of the JDK:
# ls -C1
/srv/tomcat/instances
#
TOMCAT_INSTANCE="/srv/tomcat/instances/POSWebApplication"
# echo ${TOMCAT_INSTANCE}
4. Find the name of the service for the Tomcat instance:
#
SERVICE_NAME="$(basename ${TOMCAT_INSTANCE})"
# echo ${SERVICE_NAME}
5. As the "root" user, edit the script that sets environment variables for this Tomcat instance:
# vi ${TOMCAT_INSTANCE}/bin/setenv.sh
6. Uncomment the line that sets that JAVA_HOME variable:
:%s/#readonly JAVA_HOME="";/readonly JAVA_HOME="";/g
7. Set JAVA_HOME variable to the full path to the directory from step #2.
:%s/readonly JAVA_HOME="";/readonly JAVA_HOME="/usr/java/jdk1.7.0_79";/g
8. Save your changes and quit:
:wq
9. Restart the Tomcat instance:
# service ${SERVICE_NAME} restart
10. Confirm that the Tomcat instance is using the correct version of the JDK:
# grep -h 'JVM Version:' ${TOMCAT_INSTANCE}/logs/catalina.log | tail -1
11. Send an email with output from the following commands to the Systems team:
# echo
"Hostname:
${HOSTNAME}"
# echo "JDK
directory:
${JDK_DIRECTORY}"
# echo "Tomcat
instance:
${TOMCAT_INSTANCE}"
# echo "Tomcat service
name: ${SERVICE_NAME}"