I have different projects using different version of JDK (5.0, 6.0) and Tomcat(6.0, 7.0), so how should my JAVA_HOME
and CATALINA_HOME
be set in environment variables?
Or maybe it is NOT necessary to set JAVA_HOME
and CATALINA_HOME
in environment variables if I am running my App by .War
file? The jdk/tomcat
server will be running the version I picked when I packed it (through Eclipse -> preferences...).
Inside the tomcat startup script /bin/catalina.sh
, the following environmental variables are used:
JAVA_HOME
is the path of JDK that used to run the tomcat and web applicationsCATALINA_HOME
is the path of the tomcat binaries filesCATALINA_BASE
is the path the tomcat configuration filesSo , how about this approach? For example :
Install JDK 5.0 to : /opt/jdk5
Install JDK 6.0 to : /opt/jdk6
Install tomcat 6.0 to :/opt/tomcat6
Install tomcat 7.0 to : /opt/tomcat7
Each of your web application has their own folder to hold their own tomcat 's configuration. For example :
/home/web1
for the web application 1/home/web2
for the web application 2
Inside each of these folders , we need the following sub directories: conf
, logs
, temp
, webapps
, and work
.Simply copy these sub directories from the tomcat installation folder (ie. /opt/tomcat7/
) .Then put the .war
to the corresponding webapps
folders (e.g. /home/web1/webapps/webappl.war
, /home/web2/webapps/webapp2.war
).
Finally , write a script to start the tomcat using different JDK and tomcat for each application . For example , to start web1, your script should look likes:
JAVA_HOME=/path/to/jdk #eg./opt/jdk6
CATALINA_HOME=/path/to/tomcat/installation #eg./opt/tomcat7
CATALINA_BASE=/home/web1/
export JAVA_HOME JAVA_OPTS CATALINA_HOME CATALINA_BASE
$CATALINA_HOME/bin/catalina.sh start
Reference : http://www.mohancheema.net/appserver/setting-tomcat-to-run-mutiple-instances-of-it
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