1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
/* Determine operating system using System class This example shows how to determine the operatng system JVM is running on. */ public class DetermineOS { public static void main(String[] args) { /* * Get os.name system property using * public static String getProperty(String name) method of * System class. */ 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"); } } } /* If executed on windows, Output would be Get OS name example.. OS is Windows */ |
Add Comment