Java如何获取操作系统名称和版本?
package org.nhooo.example.lang;
public class OperatingSystemInfo {
public static void main(String[] args) {
//获取操作系统名称的关键
String name = "os.name";
//获取操作系统版本的关键
String version = "os.version";
//获取操作系统体系结构的关键
String architecture = "os.arch";
System.out.println("Name : " + System.getProperty(name));
System.out.println("Version: " + System.getProperty(version));
System.out.println("Arch : " + System.getProperty(architecture));
}
}下面是我们程序的示例结果,当然,它可能与您在计算机上看到的结果不同,因为它取决于您使用的操作系统。
Name : Windows XP Version: 5.1 Arch : x86
要么
Name : Mac OS X Version: 10.12.6 Arch : x86_64
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短