Operating System Using System Class In Java

Chapter: System Last Updated: 06-04-2016 20:02:22 UTC

Program:

            /* ............... START ............... */
                
public class JavaDetermineOS {
	public static void main(String[] args) {

		String strOSName = System.getProperty("os.name");

		System.out.print("Get OS name example.. OS is ");
		if (strOSName != null) {
			if (strOSName.toLowerCase().indexOf("windows") != -1)
				System.out.println("Windows");
			else
				System.out.print("not windows");
		}
	}
}
                /* ............... END ............... */
        

Output

Get OS name example.. OS is Windows

Notes:

  • System.getProperty("os.name") to detect which type of operating system (OS) you are using now.

Tags

Operating System, Java

Similar Programs Chapter Last Updated
Java Program To Run Application System 24-06-2017
Java System.getProperties() Example System 20-04-2016
Java Classpath Using System Class System 20-04-2016
Java Specification Version Using System Class System 03-08-2016

1