本文章內容:
Tomcat的各種疑難雜症解決辦法。
Q1. 執行catalina.sh configtest.sh,"Using JRE_HOME:"這一行不是正確的路徑
# catalina.sh configtest
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr #這一行路徑不正確
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Using CATALINA_OPTS:
解決辦法:
(1) 先查看tomcat使用的java版本
# catalina.sh version
...
JVM Version: 11.0.9+11-LTS #tomcat使用的java版本
...
(2) 使用alternatives查看java的家目錄在哪
# alternatives --list
...
java auto /usr/lib/jvm/java-11-openjdk-11.0.9.11-0.el7_9.x86_64/bin/java #得知java home在/usr/lib/jvm/java-11-openjdk-11.0.9.11-0.el7_9.x86_64
...
# ll /usr/lib/jvm/jre
lrwxrwxrwx. 1 root root 21 Nov 29 03:25 /usr/lib/jvm/jre -> /etc/alternatives/jre #其實java home被許多鏈接
# ll /etc/alternatives/jre #其實java home被許多鏈接
lrwxrwxrwx. 1 root root 53 Nov 29 03:25 /etc/alternatives/jre -> /usr/lib/jvm/java-11-openjdk-11.0.9.11-0.el7_9.x86_64
(3) 在/etc/profile.d目錄下新增java.sh,並執行它
# vim /etc/profile.d/java.sh
export JAVA_HOME="/usr/lib/jvm/jre"
export PATH=$JAVA_HOME/bin:$PATH
# . /etc/profile.d/java.sh
(4) 再次執行catalina.sh configtest.sh,"Using JRE_HOME:"這一行就會顯示你想要的路徑
# catalina.sh configtest
...
Using JRE_HOME: /usr/lib/jvm/jre
...