I have 2 Java Web Projects. One runs on JDK 1.5 and the other runs on JDK 1.6. I want to run both of them on the same computer, but the JAVA_HOME environment variable can only have one value. I want to set JAVA_HOME for each Tomcat server.
To understand how Tomcat pick up which JDK to run, refer to the Tomcat startup script – /etc/init. d/tomcat7 . Normally, Tomcat will use the JDK which configured in the JAVA_HOME environment, if JAVA_HOME is not set, Tomcat will find a random JDK from a pre-defined location.
At the beginning of the script (and after the comments), place the JAVA_HOME variable and the location of the JDK that Tomcat will use. For example: Unix: JAVA_HOME=/usr/local/java/jdk1.
place a setenv.sh in the the bin directory with
JAVA_HOME=/usr/java/jdk1.6.0_43/ JRE_HOME=/usr/java/jdk1.6.0_43/jre
or an other version your running.
One thing that you could do would be to modify the catalina.sh (Unix based) or the catalina.bat (windows based).
Within each of the scripts you can set certain variables which only processes created under the shell will inherit. So for catalina.sh, use the following line:
export JAVA_HOME="intented java home"
And for windows use
set JAVA_HOME="intented java home"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With