我想把Tomcat的JVM
版本改成7。所以我按照这里的指示:如何更改TOMCAT使用的JAVA版本? 并将我的JAVA_HOME
更改为jdk7目录。
为了确保,这是命令:
$ echo $JAVA_HOME
/usr/lib/jvm/java-7-openjdk-amd64
我重新启动了Tomcat。我想要验证,于是运行了从这里得到的命令:https://dev59.com/AG025IYBdhLWcg3whGax#10822328
$ /usr/share/tomcat7/bin/catalina.sh version
/usr/share/tomcat7/bin/catalina.sh: 1: /usr/share/tomcat7/bin/setenv.sh: -Dcom.sun.management.jmxremote: not found
/usr/share/tomcat7/bin/catalina.sh: 2: /usr/share/tomcat7/bin/setenv.sh: -Dcom.sun.management.jmxremote.port=1099: not found
/usr/share/tomcat7/bin/catalina.sh: 3: /usr/share/tomcat7/bin/setenv.sh: -Dcom.sun.management.jmxremote.authenticate=false: not found
/usr/share/tomcat7/bin/catalina.sh: 4: /usr/share/tomcat7/bin/setenv.sh: -Dcom.sun.management.jmxremote.ssl=false: not found
Using CATALINA_BASE: /usr/share/tomcat7
Using CATALINA_HOME: /usr/share/tomcat7
Using CATALINA_TMPDIR: /usr/share/tomcat7/temp
Using JRE_HOME: /usr/lib/jvm/java-7-openjdk-amd64
Using CLASSPATH: /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar
Server version: Apache Tomcat/7.0.28
Server built: Apr 8 2014 08:47:08
Server number: 7.0.28.0
OS Name: Linux
OS Version: 3.16.0-0.bpo.4-amd64
Architecture: amd64
JVM Version: 1.7.0_79-b14
JVM Vendor: Oracle Corporation
我看到JVM版本是1.7.0_79-b14。
发生了什么?实际上,我开始整个过程的原因是我的war文件没有被部署,因为存在版本不匹配的问题:
Caused by: java.lang.UnsupportedClassVersionError:
org/glassfish/jersey/servlet/init/JerseyServletContainerInitializer :
Unsupported major.minor version 51.0 (unable to load class
org.glassfish.jersey.servlet.init.JerseyServletContainerInitializer)
更新 根据要求,这里是运行java -version命令的输出结果:
$ java -version
java version "1.7.0_79"
OpenJDK Runtime Environment (IcedTea 2.5.6) (7u79-2.5.6-1~deb7u1)
OpenJDK 64-Bit Server VM (build 24.79-b02, mixed mode)
echo $JRE_HOME
命令检查目标 JRE。 - SaviNuclear