You can use System.getProperty()
to get the following properties:
os.name
: operating system nameos.arch
: operating system architectureos.version
: operating system version
In your case, I believe that you are looking for the os.version
property. javadocs for System.getProperties()
contains a complete list of properties you can get.
Edit
I just tested this on Linux Mint, and it seems that getting the os.version
property actually returns the kernel version, not the distribution version:
Linux amd64 2.6.38-8-generic
After finding this message, it seems that there is no reliable way to find which Linux distribution you are using in the Java API.
If you know that you are running Linux, you can instead run one of the following system commands with Java, but you will need to run grep / parse out:
source share