You can use System.getProperty()
to get the following properties:
os.name
: Operating system name
os.arch
: Operating system architecture
os.version
: Operating system version
In your case, I believe you're looking for the os.version
property. The javadocs for System.getProperties()
contain a full list of properties that you can retrieve.
Edit
I just tested this in Linux Mint and it appears that the getting the os.version
property actually returns the kernel version, and not the distro version:
Linux
amd64
2.6.38-8-generic
After finding this post, it seems as though there's no reliable way to find which Linux distribution you're running through the Java API.
If you know you're running in Linux, you can instead run one of the following system commands from Java, but you'll have to grep/parse out the distribution: