18

I have set the JAVA_HOME to C:\Program Files\Java\jdk1.5.0_11
I have set the Classpath to C:\Program Files\Java\jre1.5.0_11

I have set the path to

C:\Ruby193\bin;C:\XEClient\bin; F:\oracle\product\10.2.0\db_2\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem; C:\Program Files\Java\jdk1.6.0_17\bin; C:\Program Files\jEdit;C:\Program Files\TortoiseSVN\bin; C:\Program Files\Microsoft SQL Server\90\Tools\binn\

Now my question is, what version of java does the tomcat run on?
The tomcat console writes the whole 'path'
and the cmd says it is java version 7 currently running in the system.
Someone please help me out.. I have java 5,6,7 versions installed in my system and also tomcat 5,6,7.
Now what is the tomcat's java version and the system's java version???

4
  • 1
    why do you need to know that?
    – gefei
    Nov 8, 2012 at 10:54
  • 1
    @gefei I am using an application which I want to test in different versions of java and different versions of tomcat. This is the reason.
    – Freakyuser
    Nov 8, 2012 at 10:58
  • Since when the Tomcat distro integrated with Java?
    – Roman C
    Nov 8, 2012 at 11:05
  • @RomanC What is tomcat distro?
    – Freakyuser
    Nov 8, 2012 at 11:10

6 Answers 6

25

You can look up the Java version Tomcat is really running with in the manager app, which is installed by default. Go to http://hostname:8080/manager/html (replace hostname by hostname or localhost), scroll to the bottom, there you will find "JVM Version".

Which JVM is selected depends a lot on the OS and way to install, maybe http://tomcat.apache.org/tomcat-7.0-doc/setup.html will help.

E.g. if you are running Windows with Tomcat with the service wrapper (I would recommend this for Windows), you can set the path to the JVM directly in the tray icon -> Configure Tomcat. In the Java tab e.g. set Java Virtual Machine to "D:\java\jdk1.6.0_35\jre\bin\server\jvm.dll" (disabled "use default") or where your JVM resides -> you need to specify the complete path to the jvm.dll.

Regarding getting to know which Java the system is running on: That's difficult to answer, there isn't really one Java version that the system is running as such. E.g. for Windows there may be one Java version set in the PATH, a potentially different one in JAVA_HOME / JRE_HOME / ..., one (or more) set in the registry, a certain version plugin active in each web browser used for applets etc. You have to check in the part you are interested in. Most good Java apps will display the version used somewhere, in logs, about dialogs or so. For Firefox you can check in the add-ons / plug-ins list. A Java exe wrapper like JSmooth can search for Java in different places and choose the most suitable, e.g. the newest, not necessarily the most "exposed".

6
  • Excellent. Thanks for the quick reply. The JVM version is 7 in the place where you said. But how do I change the version of java through which my tomcat should run?
    – Freakyuser
    Nov 8, 2012 at 11:20
  • You're welcome. If you are running Windows with Tomcat with the service wrapper (I would recommend this), you can set the path to the JVM directly in the tray icon -> Configure Tomcat. In the Java tab e.g. set JVM to "D:\java\jdk1.6.0_35\jre\bin\server\jvm.dll" or where your JVM resides.
    – FelixD
    Nov 8, 2012 at 11:24
  • Extraordinary. The only part you are yet to reply is, which java version is the system(not tomcat) currently running? How do I change it?
    – Freakyuser
    Nov 8, 2012 at 11:36
  • That's difficult, there isn't really one Java version that the system is running as such. E.g. for Windows there may be one Java version set in the PATH, a potentially different one in JAVA_HOME / JRE_HOME / ..., one set in the registry, a certain version plugin active in each web browser used for applets etc. You have to check in the part you are interested in. Most good Java apps will display the version used somewhere, in logs, about dialogs or so. For Firefox you can check in the add-ons / plug-ins list. A Java exe wrapper like JSmooth can search for Java in different places.
    – FelixD
    Nov 8, 2012 at 12:41
  • Fantastic. The answer and the comments are good. Can you please add this last comment into your answer? So that everyone can help themselves while searching something related to this.
    – Freakyuser
    Nov 8, 2012 at 15:05
20

If you don't have the manager application on your server (I didn't), then you can check it like this:

ps -ef | grep tomcat

The output should list your running server:

tomcat     741     1 87 01:07 ?        00:01:15 /usr/java/default/bin/../bin/java ...

Now you know where your java is that your tomcat was executed from you can check the version like:

/usr/java/default/bin/../bin/java -version
0
4

I found this command helpful. From your tomcat install directory.

Linux

java -cp lib/catalina.jar org.apache.catalina.util.ServerInfo

Window

java.exe -cp lib\catalina.jar org.apache.catalina.util.ServerInfo

Sample output

Server version: SpringSource tc Runtime/2.0.4.RELEASE
Server built: August 3 2010 0710
Server number: 6.0.28.29
OS Name: Linux
OS Version: 2.6.18-194.11.1.el5
Architecture: i386
JVM Version: 1.6.0_21-b06
JVM Vendor: Sun Microsystems Inc.

Reference at https://confluence.atlassian.com/confkb/how-to-determine-your-version-of-tomcat-and-java-331914173.html

1
  • 1
    This is not correct, the "sample output JVM version" will always show the version that is on the path, as displayed by java -version. The easy way to show the version that your Tomcat is currently using on Windows is to go to: http://hostname:8080/manager/html, scroll all the way down and you will see a nice formatted table named "Server Information" with the Tomcat version, JVM Version etc... Oct 15, 2020 at 3:31
2

The java version is written in the log file right after tomcat start. Just look keyword "Java Home" in Catalina log logs\catalina.yyyy-mm-dd.log.

Nov 23, 2020 3:56:19 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home:             C:\Program Files\Java\jre1.8.0_251 
2
  • Thanks a lot, that was useful! Now, how to find out where it was configured and how to change Java Home for Tomcat?
    – tarekahf
    Dec 3, 2021 at 18:56
  • definitely the best way to get it as it is printed by tomcat itself Apr 5, 2022 at 13:51
1

You can choose by altering catalina.bat/catalina.sh, your set up will use JAVA_HOME, unless you change setenv.bat.

just type java -version into your dos prompt to see your default java version, which programs will use unless you explicity tell them not to.

4
  • ya java -version says it is java 1.7. But I haven't mentioned it anywhere. That is what is confusing me.
    – Freakyuser
    Nov 8, 2012 at 11:12
  • have you set JRE_HOME aswell ? Nov 8, 2012 at 11:13
  • No I have set only JAVA_HOME in environment variables. By the way do we set JRE_HOME in environment variables?
    – Freakyuser
    Nov 8, 2012 at 11:15
  • Editing setenv.bat is the key if you want to use run.bat to run Tomcat, rather than having to use the service manager. Jan 10, 2014 at 23:01
1

If you are running Tomcat from Eclipse, the JVM version that Tomcat will use is the one that is the checked JRE in the Installed JREs.

Example:

enter image description here

Check:

enter image description here

Bonus:

If you want to find out which Tomcat's version is compatible with which version of Java, check it out here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.