Is there a OS command to find what Java version Tomcat6 is using? I need to use a Perl (including system()) command.
I using Linux. Ubuntu and CentOS
Is the
You can use the Tomcat manager app to find out which JRE and OS versions Tomcat is using. Given a user tomcat
with password password
with a role of manager
:
Tomcat 6:
curl http://tomcat:password@localhost:8080/manager/serverinfo
Tomcat 7/8:
curl http://tomcat:password@localhost:8080/manager/text/serverinfo
Or you could use the Probe application and just look at its System Info page. Much easier than writing code, and once you start using it you'll never go back to Tomcat Manager.
At first you need to understand first, that Tomcat is a Java application. So, to see which java version Tomcat is using, you can just simply find the script file from which Tomcat is started, usually catalina.sh.
Inside this file, you will get something like below:
catalina.sh:# JAVA_HOME Must point at your Java Development Kit installation.
catalina.sh:# Defaults to JAVA_HOME if empty.
catalina.sh: [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
catalina.sh: JAVA_HOME=`cygpath --absolute --windows "$JAVA_HOME"`
catalina.sh: echo "Using JAVA_HOME: $JAVA_HOME"
By default, JAVA_HOME should be empty, which mean it will use the default version of java, or you can test with: echo $JAVA_HOME
And then use "java -version" to see which version you default java is.
And vice versa by setting this property: JAVA_HOME, you can configure which Java version to use when starting Tomcat.