You can use "system.properties.os", for example:
public class GetOs {
public static void main (String[] args) {
String s =
"name: " + System.getProperty ("os.name");
s += ", version: " + System.getProperty ("os.version");
s += ", arch: " + System.getProperty ("os.arch");
System.out.println ("OS=" + s);
}
}
// EXAMPLE OUTPUT: OS=name: Windows 7, version: 6.1, arch: amd64
Here are more details:
- http://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html