How do I find what Java version Tomcat6 is using?
Solution 1
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.
Solution 2
/usr/local/tomcat6/bin/catalina.sh version
Solution 3
Once you have started tomcat simply run the following command at a terminal prompt:
ps -ef | grep tomcat
This will show the process details and indicate which JVM (by folder location) is running tomcat.
Solution 4
If tomcat did not start up yet , you can use the command \bin\cataline version
to check which JVM will the tomcat use when you start tomcat using bin\startup
In fact ,\bin\cataline version
just call the main class of org.apache.catalina.util.ServerInfo
, which is located inside the \lib\catalina.jar
. The org.apache.catalina.util.ServerInfo
gets the JVM Version and JVM Vendor by the following commands:
System.out.println("JVM Version: " +System.getProperty("java.runtime.version"));
System.out.println("JVM Vendor: " +System.getProperty("java.vm.vendor"));
So , if the tomcat is running , you can create a JSP page that call org.apache.catalina.util.ServerInfo
or just simply call the above System.getProperty()
to get the JVM Version and Vendor . Deploy this JSP to the running tomcat instance and browse to it to see the result.
Alternatively, you should know which port is the running tomcat instance using . So , you can use the OS command to find which process is listening to this port. For example in the window , you can use the command netstat -aon
to find out the process ID of a process that is listening to a particular port . Then go to the window task manager to check the full file path of this process ID belongs to. .The java version can then be determined from that file path.
Solution 5
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
Related videos on Youtube
bitbucket
Updated on July 09, 2022Comments
-
bitbucket almost 2 years
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 there something like?
tomcat6 version
-
Paŭlo Ebermann about 13 yearsDo you want to find that from inside Tomcat (i.e. a servlet or JSP or utility class), or from the outside?
-
bitbucket about 13 years@Paŭlo Ebermann see my new edits.
-
Dennis over 10 yearsI'd like to know in WINDOWS how to do that
-
ROMANIA_engineer over 8 yearsWindows:
catalina -version
(if you have the bin folder in yourPath
) or edit %CATALINA_HOME%\bin\version.bat by addingpause
at the end, then run this file (version.bat). You'll see a line containing JRE_HOME.
-
-
Shiva Krishna Bavandla about 11 yearsk how to find the tomcat version from this ?
-
bitoiu about 10 yearsthis doesn't address the users question and it seems to be oriented to a windows system.
-
Mohd Farid almost 9 yearsVery useful and accurate way to find it. Thank you
-
signonsridhar over 8 yearsthis is accurate, ps -ef | grep tomcat, shows the path of runtime java in the output. Use that java path, call /xx/yy/java -version. catalina.sh version can show a different jre_version compared to the tomcat launch version.
-
mahacoder about 8 yearsThis prints JRE_HOME. But if I do
echo $JRE_HOME
it prints nothing. Then where is tomcat getting JRE_HOME from? -
Ralph about 7 yearsWhen I run this command it states "JVM version: 1.8.0" whereas running "ps -ef | grep tomcat" -version from the answer below shows java version "1.7.0". Which of you is right?
-
jmcgrath207 almost 7 years
/opt/tomcat/bin/catalina.sh version
for tomcat 8 -
Sagiv b.g almost 7 yearsHe clearly stated that the OS he is using are: Linux. Ubuntu and CentOS. your answer related to none of them.
-
Ozl over 6 yearsGreat answer, gave me an error and within it i saw the version directory name location