Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set JAVA_HOME for multiple Tomcat instances?

Tags:

java

tomcat

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.

like image 424
Chan Pye Avatar asked Nov 09 '09 03:11

Chan Pye


People also ask

Does Tomcat use JAVA_HOME?

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.

Where is JAVA_HOME in Tomcat?

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.


2 Answers

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.

like image 65
HowRude Avatar answered Sep 23 '22 11:09

HowRude


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" 
like image 45
bogertron Avatar answered Sep 19 '22 11:09

bogertron