Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine linux version from java

I'm wondering if there's a way to determine which version of Linux I'm running (ie differentiate between RHEL4, RHEL5) from within the JVM. I'm just looking for a consistent way to differentiate between the operating systems and their versions.

like image 543
Raymond Kroeker Avatar asked Aug 26 '09 20:08

Raymond Kroeker


2 Answers

The JVM gives you some basic information about the operating system via

System.getProperty()

"os.name" // OS name
"os.arch" // OS architecture
"os.version" // OS version

As far as I know it doesn't offers distribution specific information. At least for debian distributions this information is stored in a file called

/etc/issue

So it may help reading any of the files where the different distros store this information.

like image 197
Daff Avatar answered Nov 03 '22 00:11

Daff


I do not believe there are any system properties you can look at that will give you that information. How about just executing a cat /proc/version and parsing the output.

like image 41
Rob Di Marco Avatar answered Nov 02 '22 22:11

Rob Di Marco