Centos – Change java version for tomcat on centOS

centosjavatomcat6

I need to run tomcat6 with Java 8 and keep Java 6 as the default JRE on CentOS.

I have succeeded on unpacking a tar version of tomcat6 on centOS and doing so, but when I use the yum package, for some reason, there is no catalina.sh and I cannot just run "catalina.sh" with JAVA_HOME set to whatever I want.

I have seen that on tomcat6.conf there is a variable called "JAVA_HOME" and I have set it to the right value, but it still uses java 6.

Can anybody help me?

Best Answer

As you can see from the startup script, what's getting launched is actually the script in

/usr/sbin/tomcat6

Inside there, you will find that to set its enviroment variables the script launches the function

set_java_cmd

sourced from the file

/usr/share/java-utils/java-functions

Look at that last file and you'll find everything needed to bypass the default options, the file is decently commented.

About tomcat6 being ok with the JDK8 instead, that's for you to discover :)