Java examples for java.lang:System
get OS Name
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { System.out.println(getOSName()); }/*from ww w . j av a 2 s .c o m*/ public static final String getOSName() { String osName = new String(); try { String name = System.getProperty("os.name"); if (name.startsWith("Lin")) { osName = "lin"; } else if (name.startsWith("Win")) { osName = "win"; } else if (name.startsWith("Mac")) { osName = "mac"; } else { osName = "undifined" + Math.random(); } } catch (Exception e) { osName = "undifined" + Math.random(); } return osName; } }