Tomcat and java version

How to find the tomcat version installed| check the java version used in tomcat

Sometimes, We need to find the tomcat version installed on the machine. version. sh or version.bat in the bin folder of the tomcat folder gives tomcat and java versions of the machine.

version. sh is for Linux and Unix OS version.bat is for windows

In this tutorial, Different ways we can check the installed Tomcat version.

Check the tomcat version in windows?

First, go to the installed folder on tomcat home

In my System, It is located in the B:\apache-tomcat-9.0.35 folder, Go to the bin folder

Run version.bat in the command line in windows, If you are using it on a Linux machine, you can use the version. sh

B:\apache-tomcat-9.0.35\bin>version.bat Using CATALINA_BASE: "B:\apache-tomcat-9.0.35" Using CATALINA_HOME: "B:\apache-tomcat-9.0.35" Using CATALINA_TMPDIR: "B:\apache-tomcat-9.0.35\temp" Using JRE_HOME: "A:\Java\jdk1.8.0" Using CLASSPATH: "B:\apache-tomcat-9.0.35\bin\bootstrap.jar;B:\apache-tomcat-9.0.35\bin\tomcat-juli.jar" Server version: Apache Tomcat/9.0.35 Server built: May 5 2020 20:36:20 UTC Server number: 9.0.35.0 OS Name: Windows 10 OS Version: 10.0 Architecture: amd64 JVM Version: 1.8.0_102-b14 JVM Vendor: Oracle Corporation

How to find the tomcat version in Linux/Unix?

First, Check the version.sh file located in tomcat directory bin folder in UNIX and Linux machine

Читайте также:  Free weather api python

We can use the find command to find the filename=version.sh.

sudo find / -name "version.sh"
/usr/local/content/Tomcat/apache-tomcat-8.5.37/bin/version.sh

Another way is to check process information using the ps command.

We have to find the tomcat process information using the ps command.

It gives the process id and path of the tomcat installation location.

root 7128 1 0 Aug14 ? 00:06:20 /usr/local/java/j2sdk-image//bin/java -Djava.util.logging.config.file=/usr/local//Tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Xms256m -Xmx4096m -XX:MaxPermSize=4096m -XX:OnOutOfMemoryError=/usr/bin/oom-handler -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/usr/local/Tomcat/current/logs/heap-dumps -classpath /usr/local/Tomcat/current/bin/bootstrap.jar:/usr/local/Tomcat/current/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/Tomcat/current -Dcatalina.home=/usr/local/Tomcat/current -Djava.io.tmpdir=/usr/local/Tomcat/current/temp org.apache.catalina.startup.Bootstrap start user 17624 17470 0 09:21 pts/0 00:00:00 grep --color=auto -i tomcat

Check tomcat running version using lib folder

  • Go to tomcat root folder,
  • cd lib folder
  • Run the below java command java -cp catalina.jar org.apache.catalina.util.ServerInfo
B:\apache-tomcat-9.0.35\lib>java -cp catalina.jar org.apache.catalina.util.ServerInfo Server version: Apache Tomcat/9.0.35 Server built: May 5 2020 20:36:20 UTC Server number: 9.0.35.0 OS Name: Windows 10 OS Version: 10.0 Architecture: amd64 JVM Version: 1.8.0_102-b14 JVM Vendor: Oracle Corporation

How to check the tomcat version in the JSP file

application scope object has server information

Tomcat version check using release notes

Every version of tomcat contains a RELEASE-NOTES file, You can check the file by opening the file.

With the command line, you can run the below commands from the tomcat root directory. In windows

B:\apache-tomcat-9.0.35>type RELEASE-NOTES | find "Apache Tomcat Version" Apache Tomcat Version 9.0.35

In Linux, you can use the below command.

/usr/Tomcat/apache-tomcat-8.5.37$ sudo cat RELEASE-NOTES | grep "Apache Tomcat Version" Apache Tomcat Version 8.5.37

Источник

4 Ways to Change JRE for Tomcat

Basically, an installation of Tomcat is running under the default JRE which can be found based on environment variables ( JAVA_HOME ), or registry entries (on Windows) or the JRE is specified during installation (Tomcat is installed as a service). Sometimes we need to change the default JRE for Tomcat, either for testing purposes or to run Tomcat under a targeted version of JRE. In this article, we summarize different ways to change JRE for a Tomcat installation.

To know which JRE version is used for Tomcat, go to the following URL:

localhost:8080/manager/status

And look at the JVM Version column:

See JVM version for Tomcat

1. Changing JRE by updating JAVA_HOME or JRE_HOME

This way is very simple to implement but it works only for Tomcat installed from a zip distribution (in contrast to Tomcat installed as a service).

    • If only the JAVA_HOME environment variable is set, Tomcat will run under the JRE as part of the JDK specified by the JAVA_HOME variable. Therefore, we change JRE for Tomcat by updating this variable.
    • If both the JAVA_HOME and JRE_HOME environment variables are set, the JRE_HOME is preferred. Here’s an example of a valid value for the JRE_HOME variable (path on Windows):

    Notice that updating the JAVA_HOME or JRE_HOME environment variables will affect all the applications that depend on them, so if you want to look for a more independent approach, see the second way as described below.

    2. Changing JRE by using “setenv” script

    We can change the JRE for Tomcat by setting the JRE_HOME variable in a script file called setenv.bat (on Windows) or setenv.sh (on *nix). This file does not exist by default, so create such file and place it under CATALINA_BASE\bin directory ( CATALINA_BASE is the Tomcat installation directory).

    set "JRE_HOME=C:\Program Files\Java\jdk1.7.0_03\jre" exit /b 0

    On *nix, create the setenv.sh file with the following content:

    JRE_HOME=/usr/java/jdk1.7.0_03/jre CATALINA_PID="$CATALINA_BASE/tomcat.pid"

    Note that this way only works with Tomcat installed from a zip distribution. It doesn’t apply for Tomcat installed as a service. Behind the scenes, the Tomcat’s start up script ( startup.bat / startup.sh ) will invoke the “setenv” script if it is present. One advantage of this way is that it doesn’t affect the system environment variables.

    3. Changing JRE in Tomcat service manager

    For a Tomcat installation which is installed as a service (on Windows), we can change the version of JRE that runs Tomcat by configuring the Java Virtual Machine setting in the Tomcat service manager program (e.g. Tomcat7w.exe), as shown in the following screenshot:

    Change JVM for Tomcat

    This way is very simple to perform, and it does not depend on the system environment variables JAVA_HOME or JRE_HOME .

    4. Changing JRE in Eclipse IDE

    If you are using Tomcat inside Eclipse IDE, changing the JRE version for Tomcat is also pretty easy. By default, Tomcat is running under the same JRE as Eclipse (Workbench default JRE). To change JRE version for a Tomcat runtime in Eclipse, go to the menu Window > Preferences. In the Preferences dialog, open the Server > Runtime Environments node, select a Tomcat version in the list, and then click the Edit button:

    Edit Tomcat runtime in Eclipse

    The Edit Server Runtime Environment dialog appears, select the targeted JRE version under the JRE list:

    Change JRE for Tomcat in Eclipse

    Click Finish to close this dialog, and click OK to close the Preferences dialog. Now restart Tomcat to see the effect. Note that we can spot the JRE version by looking at the Console view as shown below:

    JRE version in Console view

    Other Tomcat Tutorials:

    About the Author:

    Nam Ha Minh is certified Java programmer (SCJP and SCWCD). He started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on Facebook and watch his Java videos you YouTube.

    Add comment

    Comments

    Yes but the thing that I find difficult to remember is how to access the «Java Virtual Machine settings» when changing JRE in Tomcat service manager

    you helped me starting tomcat

    Hi Anndrey,
    Is that app based on Spring Boot? If so, Tomcat version can be changed by specifying tomcat.version property in the pom.xml file, and then rebuild the app.
    Reference: stackoverflow.com/. /.

    Hi Nam,
    I have an application running an embedded Tomcat 8.0 and at a security scan it was found as a security risk with the solution to be upgraded to version 8.5.
    The provider of the application is unable to update the application with the new Tomcat version.
    Can you please tell me if it possible to update it «manually» (by myself)?
    Thank you!

    Hi Mrityunjay,
    Java is backward-compatible, meaning that Java 1.8 will run 1.6 code well. You didn’t mention exactly what Jars not loaded and errors, so I couldn’t know the real cause of the problem.

    Источник

Оцените статью