English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Tutoriais Básicos de Java

controle de fluxo Java

Java array

Java orientação a objetos (I)

Java orientação a objetos (II)

Java orientação a objetos (III)

Tratamento de Exceções Java

Java lista (List)

Java Queue (fila)

conjunto Java Map

conjunto Java Set

Java entrada e saída (I/O)

Java Reader/Writer

temas Java outros

Java programa obter o nome e a versão do sistema operacional

Java Examples

In this example, we will learn how to use a Java program to get the current operating system's name and version.

Example: java get the name and version of the operating system

class Main {
  public static void main(String[] args) {
    //Get the operating system's name
    String operatingSystem = System.getProperty("os.name");
    System.out.println(operatingSystem);
  }
}

Output Result

Windows 10

In the above example, we used the getProperty() method of the System class. Here, we pass the os.name key as a parameter to this method.

This method returns the system property specified by the key.

There are other keys that can be used to get other system properties. For example,

//Return the operating system's version
// 10.0
System.getProperty("os.version");

Here, the key os.version returns the operating system's version.

Java Examples