如何找到 Tomcat6 使用的 Java 版本?

发布于 2024-11-06 00:16:53 字数 163 浏览 4 评论 0原文

是否有操作系统命令可以查找 Tomcat6 使用的 Java 版本? 我需要使用 Perl (包括 system())命令。

我使用Linux。 Ubuntu和CentOS

有类似的吗?

     tomcat6 version

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 there something like?

     tomcat6 version

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

梦旅人picnic 2024-11-13 00:16:53

/usr/local/tomcat6/bin/catalina.sh版本

/usr/local/tomcat6/bin/catalina.sh version

多孤肩上扛 2024-11-13 00:16:53

首先你需要先了解Tomcat是一个Java应用程序。
因此,要查看Tomcat正在使用哪个java版本,您只需找到启动Tomcat的脚本文件即可,通常是catalina.sh。

在此文件中,您将得到如下所示的内容:

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"

默认情况下,JAVA_HOME 应该为空,这意味着它将使用默认的 java 版本,或者您可以使用以下命令进行测试: echo $JAVA_HOME

然后使用“java -version”查看哪个版本你默认的java版本是。

反之亦然,通过设置此属性:JAVA_HOME,您可以配置启动 Tomcat 时使用哪个 Java 版本。

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.

如果没有你 2024-11-13 00:16:53

启动 tomcat 后,只需在终端提示符处运行以下命令:

ps -ef | grep tomcat

这将显示进程详细信息并指示哪个 JVM(按文件夹位置)正在运行 tomcat。

Once you have started tomcat simply run the following command at a terminal prompt:

ps -ef | grep tomcat

This will show the process details and indicate which JVM (by folder location) is running tomcat.

Saygoodbye 2024-11-13 00:16:53

如果tomcat还没有启动,你可以使用命令\bin\cataline version来检查当你使用bin\startup启动tomcat时,tomcat将使用哪个JVM。

事实上,\bin\cataline version 只需调用org.apache.catalina.util.ServerInfo ,位于 \lib\catalina.jar 内。 org.apache.catalina.util.ServerInfo 通过以下命令获取 JVM 版本和 JVM Vendor:

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

因此,如果 tomcat 正在运行,您可以创建一个调用 org.apache.catalina.util.ServerInfo 的 JSP 页面。 apache.catalina.util.ServerInfo 或者只是简单地调用上面的 System.getProperty() 来获取 JVM Version 和 Vendor 。将此 JSP 部署到正在运行的 tomcat 实例并浏览到它以查看结果。

或者,您应该使用 来了解正在运行的 tomcat 实例的端口。所以,你可以使用OS命令来查找哪个进程正在监听这个端口。例如,在窗口中,您可以使用命令netstat -aon 找出正在侦听特定端口的进程的进程 ID。然后转到窗口任务管理器 检查该进程ID所属的完整文件路径。。然后可以从该文件路径确定java版本。

If tomcat did not start up yet , you can use the command \bin\cataline version to check which JVM will the tomcat use when you start tomcat using bin\startup

In fact ,\bin\cataline version just call the main class of org.apache.catalina.util.ServerInfo , which is located inside the \lib\catalina.jar . The org.apache.catalina.util.ServerInfo gets the JVM Version and JVM Vendor by the following commands:

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

So , if the tomcat is running , you can create a JSP page that call org.apache.catalina.util.ServerInfo or just simply call the above System.getProperty() to get the JVM Version and Vendor . Deploy this JSP to the running tomcat instance and browse to it to see the result.

Alternatively, you should know which port is the running tomcat instance using . So , you can use the OS command to find which process is listening to this port. For example in the window , you can use the command netstat -aon to find out the process ID of a process that is listening to a particular port . Then go to the window task manager to check the full file path of this process ID belongs to. .The java version can then be determined from that file path.

享受孤独 2024-11-13 00:16:53

或者,您可以使用 Probe 应用程序,然后查看其系统信息页面。比编写代码容易得多,而且一旦开始使用它,您将永远不会回到 Tomcat Manager。

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.

很快妥协 2024-11-13 00:16:53

您可以使用 Tomcat 管理器应用程序来查找 Tomcat 正在使用的 JRE 和操作系统版本。给定一个用户 tomcat,密码为 password,角色为 manager

Tomcat 6:

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

Tomcat 7/8:

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

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
清君侧 2024-11-13 00:16:53

对于 Windows,启动 cmd 提示符并路由到 Tomcat 启动脚本所在的路径(通常是 bin)。

C:\opt\isv\tomcat-7.0\grid\bin>version
Using CATALINA_BASE:   "C:\opt\isv\tomcat-7.0\grid"
Using CATALINA_HOME:   "C:\opt\isv\tomcat-7.0\grid"
Using CATALINA_TMPDIR: "C:\opt\isv\tomcat-7.0\grid\temp"
Using JRE_HOME:        "C:\opt\isv\devtools\jdk1.8.0_45"
Using CLASSPATH:       "C:\opt\isv\tomcat-7.0\grid\bin\bootstrap.jar;C:\opt\isv\tomcat-7.0\grid\bin\tomcat-juli.jar"
Server version: Apache Tomcat/7.0.55
Server built:   Jul 18 2014 05:34:04
Server number:  7.0.55.0
OS Name:        Windows 7
OS Version:     6.1
Architecture:   x86
JVM Version:    1.8.0_45-b15
JVM Vendor:     Oracle Corporation
C:\opt\isv\tomcat-7.0\grid\bin>

For Windows, launch cmd prompt and route to the path(usually bin) where you have your tomcat startup script.

C:\opt\isv\tomcat-7.0\grid\bin>version
Using CATALINA_BASE:   "C:\opt\isv\tomcat-7.0\grid"
Using CATALINA_HOME:   "C:\opt\isv\tomcat-7.0\grid"
Using CATALINA_TMPDIR: "C:\opt\isv\tomcat-7.0\grid\temp"
Using JRE_HOME:        "C:\opt\isv\devtools\jdk1.8.0_45"
Using CLASSPATH:       "C:\opt\isv\tomcat-7.0\grid\bin\bootstrap.jar;C:\opt\isv\tomcat-7.0\grid\bin\tomcat-juli.jar"
Server version: Apache Tomcat/7.0.55
Server built:   Jul 18 2014 05:34:04
Server number:  7.0.55.0
OS Name:        Windows 7
OS Version:     6.1
Architecture:   x86
JVM Version:    1.8.0_45-b15
JVM Vendor:     Oracle Corporation
C:\opt\isv\tomcat-7.0\grid\bin>
甜尕妞 2024-11-13 00:16:53

安装tomcat后,可以在“搜索程序和文件”中搜索选择“配置tomcat”。单击“配置 Tomcat”后,您应该授予管理员权限,然后窗口将打开。然后单击“java”选项卡。在那里您可以看到 JVM 和 JAVA 类路径。

After installing tomcat, you can choose "configure tomcat" by search in "search programs and files". After clicking on "configure Tomcat", you should give admin permissions and the window opens. Then click on "java" tab. There you can see the JVM and JAVA classpath.

亚希 2024-11-13 00:16:53

要从 Windows 操作系统中找到它,

  1. 请打开命令提示符并将目录更改为 tomcat/tomee /bin 目录。
  2. 输入 catalina.bat version
  3. 它应该打印 jre 版本详细信息以及其他信息详细信息。

    使用CATALINA_BASE:“C:\User\software\enterprise-server-tome...

    使用CATALINA_HOME:“C:\User\software\enterprise-server-tome...

    使用CATALINA_TMPDIR:“C:\User\software\enterprise-server-tome...

    使用 JRE_HOME:“C:\Program Files\Java\jdk1.8.0_25”

    使用 CLASSPATH:“C:\User\software\enterprise-server-tome...

    服务器版本:Apache Tomcat/8.5.11

    服务器建成:2017年1月10日21:02:52 UTC

    服务器编号:8.5.11.0

    操作系统名称:Windows 7

    操作系统版本:6.1

    架构:amd64

    JVM版本:1.8.0_25-b18

    JVM 供应商:Oracle Corporation

To find it from Windows OS,

  1. Open command prompt and change the directory to tomcat/tomee /bin directory.
  2. Type catalina.bat version
  3. It should print jre version details along with other informative details.

    Using CATALINA_BASE: "C:\User\software\enterprise-server-tome...

    Using CATALINA_HOME: "C:\User\software\enterprise-server-tome...

    Using CATALINA_TMPDIR: "C:\User\software\enterprise-server-tome...

    Using JRE_HOME: "C:\Program Files\Java\jdk1.8.0_25"

    Using CLASSPATH: "C:\User\software\enterprise-server-tome...

    Server version: Apache Tomcat/8.5.11

    Server built: Jan 10 2017 21:02:52 UTC

    Server number: 8.5.11.0

    OS Name: Windows 7

    OS Version: 6.1

    Architecture: amd64

    JVM Version: 1.8.0_25-b18

    JVM Vendor: Oracle Corporation

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文