How to check which java version is installed

跟風遠走 提交于 2020-07-23 08:06:28

问题


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.


回答1:


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

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).



来源:https://stackoverflow.com/questions/48618622/how-to-check-which-java-version-is-installed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!