Java's "os.name" for Windows 10?

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

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

There are multiple possible workarounds, see MSDN article.

The trivial one is to exec cmd.exe /c ver.

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


This is definitely a known bug. It occurs because the os.name property gets its value from the GetVersionEx in the source code of the Windows API. GetVersionEx however,

may be altered or unavailable for releases after Windows 8.1

As per Microsoft's official website. Instead, we will need to use the IsWindows10OrGreater found in the Version Helper API functions in the versionhelpers.h file. As you probably guessed though, this file is not a Java file, it is written in C. As a result we need to include it in a somewhat roundabout way. It does take quite a bit of work (you need to program in JNI :/) but this tutorial will help you do it. Another solution is shown in this bug log, and does require less effort.


I faced the same issue, used the following workaround: The cmd command "systeminfo" returns "OS Name:" which is the right name for the OS, wrote the following function for this:

private boolean os2k10Check()
{
try{

    Process p = Runtime.getRuntime().exec("systeminfo");        /*Execute cmd command "systeminfo"*/
    BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
    String line;
    while (true) 
    {
        line = r.readLine();
        if (line == null) { break; }
        if(line.contains("OS Name:"))               /*If output contains OS Name and 2010*/
        {
        if(line.contains("2010"))
                return true;
        else
                return false;       
        }
    }
}
catch(Exception e)
    {System.out.println("Platform Type: os2010check: exception"+e);}

return false;
}