简体   繁体   中英

Tomcat on Linux (centos). Incorrect java version

I have installed Tomcat5 on CentOS 5 using the yum configuration tool. My java web application requires java 1.6 to run without errors. However, my tomcat install appears to be using java 1.4. This is confirmed when I navigate to the tomcat manager page:

Tomcat Version      JVM Version
Apache Tomcat/5.5.23    1.4.2

At the linux prompt, when I execute the command:

java -version 

It reveals:

java version "1.6.0"
OpenJDK  Runtime Environment (build 1.6.0-b09)
OpenJDK 64-Bit Server VM (build 1.6.0-b09, mixed mode)

I modifyied /etc/profile and setting JAVA_HOME, JRE_HOME, and CATALINA_HOME. When I execute tomcat5 version the following output results:

Using CATALINA_BASE:   /usr/share/tomcat5
Using CATALINA_HOME:   /usr/share/tomcat5
Using CATALINA_TMPDIR: /usr/share/tomcat5/temp
Using JRE_HOME:       /usr/lib/jvm/jre-1.6.0
Server version: Apache Tomcat/5.5.23
Server built:   Jul 27 2009 05:24:08
Server number:  5.5.23.0
OS Name:        Linux
OS Version:     2.6.18-128.1.6.el5
Architecture:   amd64
JVM Version:    1.6.0-b09
JVM Vendor:     Sun Microsystems Inc.

However, when I start tomcat and view the server information the JVM still says:

 JVM version 1.4.2

Any help is appreciated.

Thanks,

It looks like many people (both on CentOS and other platforms ) have trouble with the yum-installed version of tomcat. I tried installing it myself, and tend to agree - it looks pretty messy.

Like others in the above links, I would recommend removing the yum version and downloading the tarball version straight from http://tomcat.apache.org/ . I use this method for all of my tomcat installations (quite frequent), and have had few problems with this approach.

You can extract the tarball wherever you deem appropriate for your system (perhaps /opt ), and start it up using the startup.sh script in the bin/ directory. It should obey environment variables better than the yum version, but you can also set them in one of the properties files or scripts delivered with the application.

尝试在/ etc / sysconfig / tomcat5中设置JAVA_HOME

如果这是常规的Tomcat安装,并且您没有使用任何CentOS或yum特定的脚本,则可以将bin / startup.sh(位于Tomcat安装目录中)中的JAVA_HOME设置为Java 6的安装目录。这应强制Tomcat执行以下操作:使用正确的JDK安装。

尝试编辑/usr/bin/dtomcat5脚本。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM