从java中查找linux发行版的名称

从java中查找linux发行版的名称

本文介绍了从java中查找linux发行版的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我们正在java中编写一个小型库,需要从底层系统收集信息。我们能够从java中的系统属性中读取大部分内容,但是我们似乎无法在linux上运行时找到正确的方法来提取发行版的名称。电话

We are writing a small library in java that needs to collect information from the underlying system. We are able to read most of the stuff from system properties in java, but we cannot seem to find the right way to extract the name of the distro when run on linux. The call

System.getProperty("os.name");

返回Linux(我们也收集)但我们正在寻找一种方法来获取Ubuntu也是如此。我们在java中需要这个解决方案,并且不需要做一些/ etc / release解析

return "Linux" (which we also collect) but we are looking for a way to get e.g. "Ubuntu" as well. We need this solution in java and would like to not have to do some /etc/release parsing

推荐答案

为了可靠地执行此操作准确是不可能的,我能建议的最好是取'uname -a'的输出并使用它。

To do this reliably and accurately is impossible, the best I can suggest is to take the output of 'uname -a' and use that.

注意:这不是Java限制 - 有根本没有共同(和准确)的方法来识别分布。

Note: This is not a Java limitation - there is simply no common (and accurate) means of identifying a distribution.

这篇关于从java中查找linux发行版的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 17:15