Get Operating System Name in Java

Tags: System

In this Java core tutorial, we learn how to get the operating system name in a Java program.

How to use System.getProperty() static method to get OS name

public class Example {
    public static void main(String[] args) {
        String osName = System.getProperty("os.name");

        System.out.println(osName);
    }
}
The output is:
Windows 10

Happy Coding 😊

Get Java Version

Get User Home Directory in Java