/** JVM vendor info. */ public static final String Jvm_vendor = system.getproperty ("Java.vm.vendor"); public static final String jvm_version = system.getproperty ("Java.vm.version"); public static Final string jvm_name = system.getproperty ("Java.vm.name"); /** the Value of <tt>system.getproperty ("Java.version") </tt>. **/ public Static final string java_version = system.getproperty ("Java.version"); /** the value of <tt>system.getproperty ("Os.name") </tt>. **/ public static final string os_name = system.getproperty ("Os.name"); /** true iff running on linux. */ public static final boolean linuX = os_name.startswith ("Linux"); /** true iff running on windows . */ public static final boolean windows = os_name.startswith (" Windows "); /** true iff running on sunos. */ public Static final boolean sun_os = os_name.startswith ("SunOS"); /** true iff running on Mac OS X */ public static final Boolean mac_os_x = os_name.startswith ("Mac os x"); /** true iff running on freebsd */ public static final boolean free_bsd = os_name.startswith ("FreeBSD"); public static final string os_arch = system.getproperty ("Os.arch"); public static final string os_ Version = syStem.getproperty ("Os.version"); public static final string java_vendor = system.getproperty ("Java.vendor");
The above code is excerpted from the Lucene org.apache.lucene.util.Constants class
Alternatively, you can use the following method:
private static String OS = System.getproperty ("Os.name"). toLowerCase ();/** * Determine if Windows * * @return */public static bool Ean Iswindows () {return os.indexof ("Win") >= 0;} public static Boolean Ismac () {return (Os.indexof ("Mac") >= 0);} public static Boolean Isunix () {return (Os.indexof ("Nix") >= 0 | | Os.indexof ("Nux") >= 0 | | Os.indexof ("Aix") > 0);} public static Boolean Issolaris () {return (Os.indexof ("SunOS") >= 0);}
The above code reference: http://www.java-gaming.org/index.php?topic=14110.0
Java code Slice to determine system information such as the operating system