如果我有超过1个版本用于项目,如何设置JAVA_HOME或CATALINA_HOME? [英] How to set JAVA_HOME or CATALINA_HOME if I have more than 1 version used for Projects?
问题描述
我有不同的项目使用不同版本的JDK(5.0,6.0)和Tomcat(6.0,7.0),那么我的 JAVA_HOME
和应该怎样? CATALINA_HOME
是否在环境变量中设置?
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?
或者可能没有必要设置 JAVA_HOME
.War 文件运行我的应用程序,那么环境变量中的>和 CATALINA_HOME
? jdk / tomcat
服务器将运行我打包时的版本(通过Eclipse - >首选项...)。
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...).
推荐答案
在tomcat启动脚本 /bin/catalina.sh
中,使用以下环境变量:
Inside the tomcat startup script /bin/catalina.sh
, the following environmental variables are used:
-
JAVA_HOME
是用于运行tomcat和web应用程序的JDK路径 -
CATALINA_HOME
是tomcat二进制文件的路径 -
CATALINA_BASE
是tomcat配置文件的路径
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 files
那么,这种方法怎么样?例如:
So , how about this approach? For example :
将JDK 5.0安装到: / opt / jdk5
安装JDK 6.0到: / opt / jdk6
将tomcat 6.0安装到: / opt / tomcat6
将tomcat 7.0安装到: / opt / tomcat7
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
每个您的Web应用程序有自己的文件夹来保存自己的tomcat配置。例如:
/ home / web1
用于Web应用程序1
/ home / web2
用于Web应用程序2
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
在每个文件夹中,我们需要以下子目录: conf
, logs
, temp
, webapps
,和工作
。从tomcat安装文件夹中复制这些子目录(即 / opt / tomcat7 /
)。然后将 .war
放到相应的 webapps
文件夹中(例如 / home / web1 / webapps /webappl.war
, /home/web2/webapps/webapp2.war
)。
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
).
最后,编写一个脚本来为每个应用程序使用不同的JDK和tomcat启动tomcat。例如,要启动web1,您的脚本应该看起来像:
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
参考:
http://www.mohancheema.net/appserver/setting-tomcat-to-run-mutiple-instances-of -it
这篇关于如果我有超过1个版本用于项目,如何设置JAVA_HOME或CATALINA_HOME?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!