标签:Lucene http java os io ar art 代码 linux
/** 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");
以上代码摘自Lucene org.apache.lucene.util.Constants类
另外还可以用下面的方式:
private static String OS = System.getProperty("os.name").toLowerCase(); /** * 判断是否Windows * * @return */ public static boolean 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); }
以上代码参考:http://www.java-gaming.org/index.php?topic=14110.0
标签:Lucene http java os io ar art 代码 linux
原文地址:http://my.oschina.net/jasonultimate/blog/306556