Get Operating System name in Java

Single statement is enough for getting OS name in Java. So simple.

Get OS Name

class OSName
public static void main(String args[])

System.getProperty(""): This method is used for getting the value of specified property in Java. The property means the name of the OS.

Sample Output

Windows NT (unknown)

My OS is Windows 8 Release Preview, it does not properly detect it. Works for other operating systems.

Posted by at on

Tags: java.lang, System Properties,