Recently I moved on a brand new machine 64-bit Windows 7. But when I run this code, getting the incorrect OS name
String osName = System.getProperty("os.name");
System.out.println("OS Name = " + osName);
The output comes:
OS Name = Windows Vista
Any idea, what is wrong in my code or system?
Thanks in Advance.
You might be using an older version of Java. As this was a known bug(bug_id=6819886) that has been fixed in the newer versions. Kindly read this for further details.
A possible workaround for this in case you are not able to upgrade your java version:
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
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With