Java#39;s quot;os.namequot; for Windows 10?(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 表示 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...
问题是:我刚刚使用发布的 Microsoft 更新程序将我的 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"));
}
}
如何为此创建解决方法?而且,有谁知道如果安装新的 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Java 的“os.name"适用于 Windows 10?
基础教程推荐
- Struts2 URL 无法访问 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
