Dennis
Dennis

Reputation: 757

IN WINDOWS, How do I find what Java version Tomcat is using?

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.

Upvotes: 1

Views: 2031

Answers (3)

Sai Ye Yan Naing Aye
Sai Ye Yan Naing Aye

Reputation: 6738

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

<%= application.getServerInfo() %>

Then please check this oracle documentation.

Upvotes: 0

Paul Vargas
Paul Vargas

Reputation: 42020

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>

Upvotes: 1

Keerthivasan
Keerthivasan

Reputation: 12880

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

Upvotes: 0

Related Questions