如何检查安装了哪个Java版本 [英] How to check which java version is installed

查看:79
本文介绍了如何检查安装了哪个Java版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

chef客户端已经安装了Java。如何检查使用Chef安装的Java版本。我知道我可以编写一个小的ohai插件来执行相同的操作,但是还有其他方法可以检查客户端上安装了哪个Java版本吗? Java安装不是rpm安装,尽管在某些端点上可能是rpm安装。

The chef client already has java installed on it. How can I check which version of java is installed using chef. I know I can write a small ohai plugin to do the same but is there any other way to check which java version is installed on the client? The java installation is not an rpm installation though on some endpoints it might be an rpm installation.

推荐答案

我们已经尝试查询它在Ohai中为您服务: https://github.com /chef/ohai/blob/master/lib/ohai/plugins/java.rb

We already attempt to query it in Ohai for you: https://github.com/chef/ohai/blob/master/lib/ohai/plugins/java.rb

但是,这很复杂,因为您可以并行安装多个Java只要为每个应用程序设置 $ JAVA_HOME 而不是其他任何值,并且JVM文件位置没有整体标准,那么如果您认为您可能有多个版本或只有一个版本但是在 $ PATH 上,您需要在自己的配方中使用类似于Ohai插件的代码(或者,如果您想花哨的话,也可以使用自己的Ohai插件)。

However this is complicated because you can have multiple Java installs in parallel as long as you set $JAVA_HOME and whatnot for each application, and there is no overall standard for JVM file locations, so if you think you might have multiple versions or just one version but off $PATH you'll need to use code similar to the Ohai plugin in your own recipe (or your own Ohai plugin if you wanted to get fancy).

这篇关于如何检查安装了哪个Java版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆