最近我移动了一台全新的64位
Windows 7机器.但是当我运行这个代码,得到不正确的操作系统名称
String osName = System.getProperty("os.name"); System.out.println("OS Name = " + osName);
输出来:
OS Name = Windows Vista
任何想法,我的代码或系统有什么问题?
提前致谢.
解决方法
您可能会使用旧版本的Java.因为这是在较新版本中已经修复的已知错误(bug_id = 6819886).
Kindly read this for further details.
Kindly read this for further details.
String osName = System.getProperty("os.name"); if (osName.equals("Windows XP") || osName.equals("Windows Vista")) { //do something and remember to put in all the names in the above if list. I just added two for example,it will have to include all like Windows NT,ME,95,etc. } else { //the block that will be accessible for Windows 7 }