未加星标

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

字体大小 | |
[系统(linux) 所属分类 系统(linux) | 发布者 店小二04 | 时间 2016 | 作者 红领巾 ] 0人收藏点击收藏

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 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 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 necessaryPATH andClasspath 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

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 orJRE_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 and 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.

Other Apache Tomcat tutorials and Guides you may like:

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? (

本文系统(linux)相关术语:linux系统 鸟哥的linux私房菜 linux命令大全 linux操作系统

主题: TomcatWindowsLinuxJavaJVMSQLMySQL
分页:12
转载请注明
本文标题:2 Ways to find Tomcat and Java Version in Linux and Windows
本站链接:http://www.codesec.net/view/485561.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(linux) | 评论(0) | 阅读(22)