Java Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 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"); } } } |
Output:
1 2 3 | Get OS name example.. OS is Windows |
System.getProperty(“os.name”) to detect which type of operating system (OS) you are using now.