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