public class Test { public static void main(String aa[]) { if (System.getProperty("os.name").equals("Linux")) { System.out.println("linux"); } else if (System.getProperty("os.name").equals("Windows XP")) { System.out.println("windows"); } } } 使用的是以前提到过的System.getProperty().函数