Java的“os.name”对于Windows 10? [英] Java's "os.name" for Windows 10?

查看:392
本文介绍了Java的“os.name”对于Windows 10?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Java中,我们可以看到 os.name 的属性值,以了解底层操作系统的名称: System.getProperty( os.name)

In Java, we can see the property value of os.name to know the name of the underlying operating system: System.getProperty("os.name").

对于每个版本的Windows,它总是返回操作系统的确切名称: Windows XP for XP, Windows Vista for Vista, Windows 7 for Seven, Windows 8.1 8.1,依此类推......

For each edition of Windows, it used to return always the exact name of the OS: Windows XP for XP, Windows Vista for Vista, Windows 7 for Seven, Windows 8.1 for 8.1, and so on...

问题是:我刚刚将Windows 8.1更新为Windows 10使用发布的Microsoft更新程序,似乎此属性仍然是 Windows 8.1

The problem is: I just updated my Windows 8.1 to Windows 10 using the released Microsoft updater, and it seems like this property still remains Windows 8.1:

public class OSTest {
  public static void main(String[] args) {
    System.out.println(System.getProperty("os.name"));
  }
}

如何为此创建解决方法?并且,有人知道如果安装一个新的Windows 10副本这个问题是否仍然存在 - 也就是说,这个错误是由Microsoft自动更新程序引起的??

How can I create a workaround for this? And, does anyone know if this problem persists if installing a fresh Windows 10 copy - that is, this bug is caused by the Microsoft auto-updater -?

推荐答案

JDK-8066504 已知问题已在未来的Java中修复8更新60。

This is a known problem JDK-8066504 that has been fixed in upcoming Java 8 update 60.

原因是 GetVersionEx 函数已经改变了自Windows 8.1以来的行为。

The reason is GetVersionEx function has changed its behavior since Windows 8.1.

有多种可能的解决方法,请参阅MSDN文章

There are multiple possible workarounds, see MSDN article.

琐碎的是执行 cmd.exe / c ver

另一种是查看其中一个的版本信息系统文件,例如 kernel32.dll

The other is to look at the version information of one of the system files, e.g. kernel32.dll.

这篇关于Java的“os.name”对于Windows 10?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆