1

The title tells it all. I searched the web and here, and nothing was easy or clear or obvious, except for perhaps making a JSP page with the follwing in it:

System.out.println("JVM Version: " +System.getProperty("java.runtime.version"));
System.out.println("JVM Vendor: " +System.getProperty("java.vm.vendor"));

I did see this SOF question about Linux, but I knew that already.

Community
  • 1
  • 1
Dennis
  • 747
  • 7
  • 15

3 Answers3

1

You can try the next in a JSP:

<!DOCTYPE html>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Tomcat Version</title>
    </head>
    <body>
        <h2>Tomcat Version</h2>
        <pre><%=pageContext.getServletContext().getServerInfo()%></pre>
        <h2>Servlet Version</h2>
        <pre><%=pageContext.getServletContext().getMajorVersion()%>.<%=pageContext.getServletContext().getMinorVersion()%></pre>
    </body>
</html>

Sorry, scriptlets are no longer recommended. Better with JSTL:

<!DOCTYPE html>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Tomcat Version</title>
    </head>
    <body>
        <h2>Tomcat Version</h2>
        <pre>${pageContext.servletContext.serverInfo}</pre>
        <h2>Servlet Version</h2>
        <pre>${pageContext.servletContext.majorVersion}.${pageContext.servletContext.minorVersion}</pre>
    </body>
</html>
Paul Vargas
  • 41,222
  • 15
  • 102
  • 148
0

You can go through the catalina.bat file to know about the Java version, which is located in bin directory. You can also set your preferred JDK in this file by setting "JAVA_HOME" pointing to your Java Development Kit Installation. You can make the @echo ON to get more information about the environment. This is generally used for debugging and checking the ENV parameters.BY default, tomcat will choose the default Java version. echo $JAVA_HOME and java -version to find out more details

Keerthivasan
  • 12,760
  • 2
  • 32
  • 53
  • tomcat tries other java versions first, then settles for the default java. 'echo'ing $JAVA_HOME doesn't reflect the java version in the link '/usr/lib/jvm/java-default', Just what is in /etc/environment modified by /etc/bash.bashrc and /etc/profile followed by ~/.bashrc or ~/.profile. When JAVA is used during the start up of any service, only the /etc/environment seems to have any effect. YMMV, but that's whay I find on Ubuntu 12.04 – Dennis Oct 23 '13 at 03:06
0

You can get your server information from ServletContext. See this sample;

<%= application.getServerInfo() %>

Then please check this oracle documentation.

Paul Vargas
  • 41,222
  • 15
  • 102
  • 148
Sai Ye Yan Naing Aye
  • 6,622
  • 12
  • 47
  • 65