How do I find what Java version Tomcat6 is using?

后端 未结 9 955
面向向阳花
面向向阳花 2020-12-13 17:40

Is there a OS command to find what Java version Tomcat6 is using? I need to use a Perl (including system()) command.

I using Linux. Ubuntu and CentOS

Is the

相关标签:
9条回答
  • 2020-12-13 18:06

    You can use the Tomcat manager app to find out which JRE and OS versions Tomcat is using. Given a user tomcat with password password with a role of manager:

    Tomcat 6:

    curl http://tomcat:password@localhost:8080/manager/serverinfo
    

    Tomcat 7/8:

    curl http://tomcat:password@localhost:8080/manager/text/serverinfo
    
    0 讨论(0)
  • 2020-12-13 18:11

    Or you could use the Probe application and just look at its System Info page. Much easier than writing code, and once you start using it you'll never go back to Tomcat Manager.

    0 讨论(0)
  • 2020-12-13 18:13

    At first you need to understand first, that Tomcat is a Java application. So, to see which java version Tomcat is using, you can just simply find the script file from which Tomcat is started, usually catalina.sh.

    Inside this file, you will get something like below:

    catalina.sh:#   JAVA_HOME       Must point at your Java Development Kit installation.
    catalina.sh:#                   Defaults to JAVA_HOME if empty.
    catalina.sh:  [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
    catalina.sh:  JAVA_HOME=`cygpath --absolute --windows "$JAVA_HOME"`
    catalina.sh:    echo "Using JAVA_HOME:       $JAVA_HOME"
    

    By default, JAVA_HOME should be empty, which mean it will use the default version of java, or you can test with: echo $JAVA_HOME

    And then use "java -version" to see which version you default java is.

    And vice versa by setting this property: JAVA_HOME, you can configure which Java version to use when starting Tomcat.

    0 讨论(0)
提交回复
热议问题