問題描述
在Java中,我們可以通過查看os.name
的屬性值來知道底層操作系統(tǒng)的名稱: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,它總是返回操作系統(tǒng)的確切名稱:Windows XP
表示 XP,Windows Vista
表示 Vista,Windows 7
代表 7,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...
問題是:我剛剛使用發(fā)布的 Microsoft 更新程序?qū)⑽业?Windows 8.1 更新到了 Windows 10,而且這個屬性似乎仍然存在 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"));
}
}
如何為此創(chuàng)建解決方法?而且,有誰知道如果安裝新的 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 已在即將發(fā)布的 Java 8 更新 60 中修復(fù).
This is a known problem JDK-8066504 that has been fixed in upcoming Java 8 update 60.
原因是 GetVersionEx 函數(shù)的行為自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.
最簡單的就是執(zhí)行cmd.exe/c ver
.
另一種是查看其中一個系統(tǒng)文件的版本信息,例如kernel32.dll
.
The other is to look at the version information of one of the system files, e.g. kernel32.dll
.
這篇關(guān)于Java 的“os.name"適用于 Windows 10?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!