Get operating system name and version in Java
Description
The following code shows how to get operating system name and version.
Example
//w w w . ja va2 s .c om
public class Main {
public static void main(String[] args) {
String name = "os.name";
String version = "os.version";
String architecture = "os.arch";
System.out.println("Name: " + System.getProperty(name));
System.out.println("Version: " + System.getProperty(version));
System.out.println("Architecture: " + System.getProperty(architecture));
}
}
The code above generates the following result.