一台机子上运行使用不同Java版本的多个tomcat

时间:2023-03-10 00:11:59
一台机子上运行使用不同Java版本的多个tomcat

方法

在tomcat/bin/下创建setenv.sh并写入 export JAVA_HOME=/usr/share/jvm/jdk1..0_91

When you starting tomcat using catalina.sh, it searching for file setenv.sh and sourcing it. It is searching in CATALINA_HOME or CATALINA_BASE.

即启动tomcat时会先在bin/下找setenv.sh,如果里面设置了JAVA_HOME则优先用之。

Setting JAVA_HOME in setenv.sh gives you ability to use different tomcats with different applications that need different version of java, 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实例监听的端口不同。