Узнать версию tomcat linux

2 Ways to find Tomcat and Java Version in Linux and Windows — Example

You can find Tomcat and java version running on Linux either by executing the org.apache.catalina.util.ServerInfo class from catalina.jar or by executing version.sh shell script. The first solution will work on any operating system including Windows and UNIX because it’s using a Java class from a catalina.jar file, which is platform-independent. Though, if you don’t know how to run a class from the JAR file, you can check the steps here. Alternatively, you also have a version.bat file inside tomcat/bin directory to check the version of Tomcat in Windows.

When you run this script in Linux or Windows it prints information about tomcat version, the java version used to run tomcat, Server built to date, OS name, OS Version, architecture, JVM version, and JVM vendor, etc.

Behind the scene, this batch file is also running the ServerInfo class from catalina.jar but it set the necessary PATH and Classpath variable for you. It’s much convenient to run either version.sh in Linux or version.bat in Windows to get the Tomcat version.

2 ways to find Apache Tomcat version in UNIX and Windows

As discussed in the last paragraph, we need to run the ServerInfo class from catalinar.jar to get the Tomcat version and other meta-data. Let’s see examples of using these two ways to find tomcat and java version running tomcat in Windows first, followed by Linux and UNIX.

Solution 1 (Running ServerInfo class) :
a) go to tomcat installation directory and run following command :

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

Here is how you get tomcat version in Windows :

C:\Program Files\Apache Software Foundation\Apache Tomcat 7.0.41>java -cp lib/catalina.jar org.apache.catalina.util.ServerInfo
Server version: Apache Tomcat/7.0.41
Server built: Jun 6 2013 11:16:08
Server number: 7.0.41.0
OS Name: Windows 8
OS Version: 6.2
Architecture: amd64
JVM Version: 1.7.0_51-b13
JVM Vendor: Oracle Corporation

Читайте также:  Linux openvpn dns push

By the way, If you don’t have catalina.jar in your tomcat/lib folder then you may get :

Exception in thread «main» java.lang.NoClassDefFoundError: org/apache/catalina/util/ServerInfo
Caused by: java.lang.ClassNotFoundException: org.apache.catalina.util.ServerInfo
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

In that case, just check if version.sh or vesion.bat is present in tomcat/bin directory as suggested in our second solution. But, if you are getting this error even if you have catalina.jar in the tomcat/lib folder, please check out some of the steps given in my article 3 ways to solve NoClassDefFoundError in Java to troubleshoot further.

Solution 2 (using version.sh or version.bat) :
1) Go to tomcat/bin directory
2) Execute version.sh in Linux or version.bat in Windows

C:\Program Files\Apache Software Foundation\Apache Tomcat 7.0.41\bin>version.bat
Using CATALINA_BASE: «C:\Program Files\Apache Software Foundation\Apache Tomcat 7.0.41»
Using CATALINA_HOME: «C:\Program Files\Apache Software Foundation\Apache Tomcat 7.0.41»
Using CATALINA_TMPDIR: «C:\Program Files\Apache Software Foundation\Apache Tomcat 7.0.41\temp»
Using JRE_HOME: «C:\Program Files\Java\jdk1.7.0_51»
Using CLASSPATH: «C:\Program Files\Apache Software Foundation\Apache Tomcat 7.0.41\bin\bootstrap.jar;C:\Program Files\Apache Soft
ware Foundation\Apache Tomcat 7.0.41\bin\tomcat-juli.jar»
Server version: Apache Tomcat/7.0.41
Server built: Jun 6 2013 11:16:08
Server number: 7.0.41.0
OS Name: Windows 8
OS Version: 6.2
Architecture: amd64
JVM Version: 1.7.0_51-b13
JVM Vendor: Oracle Corporation

It’s important to define either JAVA_HOME or JRE_HOME to run version.bat, otherwise, you will get following error :

C:\Program Files\Apache Software Foundation\Apache Tomcat 7.0.41\bin>version.bat
Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variables is needed to run this program

The «Server version» field is the Tomcat version running on that machine. version.sh also prints additional information related to JVM and JRE version used to run tomcat in Linux or Windows.

If you are developing Java application in Tomcat, you can also learn more about Tomcat by reading Developing Java application in Tomcat, Eclipse Mars, and MySQL.

2 Ways to find Tomcat + Java Version in Linux and Windows

That’s all about how to find Tomcat version in Linux and Windows. By using version.sh, you can also find the Java version used to run tomcat. If you want to use a platform independent approach then just run ServerInfo class from catalina.jar, which you can find inside tomcat/lib directory. If you don’t have that JAR in lib directory then check for version.sh or version.bat file in tomcat/bin directory, running them will give you all the information you want about your tomcat installation.

  • How to configure HTTPS in Tomcat 6 and 7? (tutorial)
  • How to setup JNDI database connection pool in Tomcat? (guide)
  • Difference between a Web server, Application server and Servlet container? (answer)
  • How to fix java.lang.OutOfMemoryError: PermGen space in Tomcat (guide)
  • How to fix java.net.BindException: Cannot assign requested address: JVM_Bind in Tomcat (fix)
  • How to fix java.lang.OutOfMemoryError: java heap space in Tomcat (tutorial)
  • How to fix ThreadLocal memory leak in Tomcat? (solution)
  • How to fix java.net.SocketException: Too many open files in Tomcat? (tutorial)
  • How to fix java.net.BindException: Address already in use: JVM_Bind:8080 (solution)
  • Why you shouldn’t call System.exit() in Tomcat? (article)
Читайте также:  Linux run on gpu

Источник

How to Check Tomcat Version in Linux

Have you ever run into a situation where you needed to find information about a server but nobody had bothered document anything they did when they set it up? Are you administering a Linux server and just want to find out what version of Tomcat was installed? Are you a developer who wants to make sure your operations team installed the correct package in production? Maybe you’re a student who just wants to know how things work. Today we are going to show you how to check Tomcat version in Linux.

How to Check Tomcat Version in Linux Command Line

You can usually figure this out very easily by just looking at the running process. You should be able to see that path it is running from. This will typically contain the version number embedded right in the directoyr name. Use this command:

Here is an example of what the output looks like and what you want to keep an eye out for.

How to Check Tomcat Version in Linux - check the running process

Alternate Method — The “Right” Way

What if the path doesn’t contain the version? What if someone decided to use a more generic name for the directory for some reason? They might have just created a symlink. If so you can just see where that link is pointing. If not, there is another way of knowing which version of tomcat you have. This is really the best method. You can use the included version script. You will need to adjust your path but you can use this command:

 /home/user1/tomcat/bin/version.sh 

Here is what the output looks like. It includes all of the information you could possibly want.

Читайте также:  Linux с самого начала

How to Check Tomcat Version in Linux - use the version.sh script

If it happens to be a symlink:

How to Check Tomcat Version in Linux - check the symlink

More Options

Here is another creative method you might want to try:

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

If you happen to have the ability to upload a JSP page you can create something like this that tells you what version you are running:

Tomcat Version :
Servlet Specification Version : .
JSP version :

Источник

How to Check Tomcat Version on Linux

Tomcat installation provides an shell script version.sh for the Linux-based systems and version.bat for Windows systems. This script provides detailed information about the Tomcat version and other details. This quick blog post will help you to find the Tomcat version installed on your system.

Check Tomcat Version

  1. Use the cd command to switch to the Tomcat installation bin directory. The location of the directory depends on the installation types. The packages installed on the official repository are generally installed under the /etc/tomcat directory. Custom installation is generally done under the /opt or /usr/share directory.
Using CATALINA_BASE: /usr/share/tomcat Using CATALINA_HOME: /usr/share/tomcat Using CATALINA_TMPDIR: /usr/share/tomcat/temp Using JRE_HOME: /usr Using CLASSPATH: /usr/share/tomcat/bin/bootstrap.jar:/usr/share/tomcat/bin/tomcat-juli.jar Using CATALINA_OPTS: Server version: Apache Tomcat/10.0.23 Server built: Jul 14 2022 08:16:11 UTC Server number: 10.0.23.0 OS Name: Linux OS Version: 5.15.0-47-generic Architecture: amd64 JVM Version: 17.0.1+12-LTS-39 JVM Vendor: Oracle Corporation

Here is the screenshot of the Tomcat version running on a Ubuntu 22.04 system. I have recently installed it from the source code.

Check Tomcat Version

Note: If you don’t know the installation directory. You can try the following commands to find it.

find / -type d -name "*tomcat*" find / -type f -name version.sh 

Conclusion

It’s a good practice to keep servers up to date. You may also need to check the currently installed Tomcat version to find if a newer version is available. This blog post will help you to find the Tomcat version via the command line interface.

Источник

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