如何找到 Tomcat6 使用的 Java 版本?
是否有操作系统命令可以查找 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
首先你需要先了解Tomcat是一个Java应用程序。
因此,要查看Tomcat正在使用哪个java版本,您只需找到启动Tomcat的脚本文件即可,通常是catalina.sh。
在此文件中,您将得到如下所示的内容:
默认情况下,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:
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.
启动 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.
如果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:因此,如果 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 usingbin\startup
In fact ,
\bin\cataline version
just call the main class oforg.apache.catalina.util.ServerInfo
, which is located inside the\lib\catalina.jar
. Theorg.apache.catalina.util.ServerInfo
gets the JVM Version and JVM Vendor by the following commands:So , if the tomcat is running , you can create a JSP page that call
org.apache.catalina.util.ServerInfo
or just simply call the aboveSystem.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.或者,您可以使用 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.
您可以使用 Tomcat 管理器应用程序来查找 Tomcat 正在使用的 JRE 和操作系统版本。给定一个用户
tomcat
,密码为password
,角色为manager
:Tomcat 6:
Tomcat 7/8:
You can use the Tomcat manager app to find out which JRE and OS versions Tomcat is using. Given a user
tomcat
with passwordpassword
with a role ofmanager
:Tomcat 6:
Tomcat 7/8:
对于 Windows,启动 cmd 提示符并路由到 Tomcat 启动脚本所在的路径(通常是 bin)。
For Windows, launch cmd prompt and route to the path(usually bin) where you have your tomcat startup script.
安装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.
要从 Windows 操作系统中找到它,
catalina.bat version
它应该打印 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,
catalina.bat version
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