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.





















Home »
  Java Tutorial »
    Development »




Java Algorithms
Java Clipboard
Java Compiler
Java Desktop
Java Virtual Machine
Java Math
OS
Random
Java Robot
Java RuntimeMXBean
Java Timer
Java UUID
Java Internationalization