public class Test { public static void main(String[] args) throws Exception { Boolean flag = isLinux(); System.out.println("flag: " + flag); } /** * Determine whether it is Linux or Windows, if Linux returns true, if Windows returns false */ private static Boolean isLinux() { String os = System.getProperty("os.name"); System.out.println("os.name: " + os); if (os.toLowerCase().startsWith("win")) { return false; } return true; } }