How do I obtain Linux distribution version in java

174 Views Asked by At

I'm writing a spring boot app where I am required to fetch the Linux distribution version within a function. For example, if my app is running on an Ubuntu-16.04 machine, then I would like to know this version within my method. Or if I'm working on CentOS 6.9, then the method should return this.

I found that jvm stores some system properties which has os name, version and architecture. But the problem is that I have no way of determining the distribution from the kernel version number.

There is also the method of reading /etc/os-release, but this file is not present in older versions of centos. I also found that /proc/version is not always present.

Is there a generic way to obtain this distribution value?

0

There are 0 best solutions below