一台机子上运行使用不同Java版本的多个tomcat
方法
在tomcat/bin/下创建setenv.sh并写入 export JAVA_HOME=/usr/share/jvm/jdk1.8.0_91
When you starting
tomcat
usingcatalina.sh
, it searching for filesetenv.sh
and sourcing it. It is searching inCATALINA_HOME
orCATALINA_BASE
.即启动tomcat时会先在bin/下找setenv.sh,如果里面设置了JAVA_HOME则优先用之。
Setting
JAVA_HOME
insetenv.sh
gives you ability to use different tomcats with different applications that need different version ofjava
, but running by one user. Other user environment would not be affected by you.
相关:http://askubuntu.com/questions/468772/tomcat-does-not-recognize-java-home
当然,还需要修改监听端口,使不同tomcat实例监听的端口不同。