代码如下
public static void main(String[] args) {
String os = System.getProperty("os.name");
//Windows操作系统
if (os != null && os.toLowerCase().startsWith("windows")) {
System.out.println(String.format("当前系统版本是:%s", os));
} else if (os != null && os.toLowerCase().startsWith("linux")) {//Linux操作系统
System.out.println(String.format("当前系统版本是:%s", os));
} else { //其它操作系统
System.out.println(String.format("当前系统版本是:%s", os));
}
}
参考自:https://blog.csdn.net/qq_19309473/article/details/121910780