Java program to get the Operating System details
KW.java
class KW
{
    public static void main(String args[])
    {
        System.out.println("OS Name: "+System.getProperty("os.name"));
        System.out.println("OS Version: "+System.getProperty("os.version"));
        System.out.println("OS Architecture: "+System.getProperty("os.arch"));
        
        System.out.println("Java Version: "+System.getProperty("java.version"));
        System.out.println("Java Vendor URL: "+System.getProperty("java.vendor.url")); 
    }
}
Output
kodingwindow@kw:~$ javac KW.java
kodingwindow@kw:~$ java KW OS Name: Linux OS Version: 6.2.0-33-generic OS Architecture: amd64 Java Version: 21 Java Vendor URL: https://java.oracle.com/ kodingwindow@kw:~$
Equivalent Linux commands to get the Operating System details
kodingwindow@kw:~$ uname
Linux

kodingwindow@kw:~$ uname -s
Linux

kodingwindow@kw:~$ uname -r
6.2.0-33-generic

kodingwindow@kw:~$ javac --version
javac 21

kodingwindow@kw:~$ java --version
java 21 2023-09-19 LTS
Java(TM) SE Runtime Environment (build 21+35-LTS-2513)
Java HotSpot(TM) 64-Bit Server VM (build 21+35-LTS-2513, mixed mode, sharing)
kodingwindow@kw:~$ 
Equivalent Windows commands to get the Operating System details
> systeminfo
OS Name:                   Microsoft Windows 11 Home Single Language
OS Version:                10.0.22621 N/A Build 22621
System Type:               x64-based PC
...
> javac --version
javac 21

> java --version
java 21 2023-09-19 LTS
Java(TM) SE Runtime Environment (build 21+35-LTS-2513)
Java HotSpot(TM) 64-Bit Server VM (build 21+35-LTS-2513, mixed mode, sharing)
Advertisement