-1

I running java application and get a conflict on operating system name and build number.

Sample Code (On Java 1.6.0_31)

System.out.println("OS Name " + System.getProperty("os.name"));
System.out.println("Version "+System.getProperty("os.version"));

Output:

OS Name Windows NT (unknown)
Version 6.2

and

Sample Code (On Java 1.8.0_45)

System.out.println("OS Name " + System.getProperty("os.name"));
System.out.println("Version "+System.getProperty("os.version"));

Output:

OS Name Windows Server 2012 R2
Version 6.3

Why i am getting like this can explain?

naveen
  • 72
  • 1
  • 9
  • Both versions of Java are severely outdated within their branches, so it's most likely just a bug. See eg. answer for https://stackoverflow.com/questions/31909107/javas-os-name-for-windows-10 – Piotr Wilkin Nov 16 '17 at 11:09
  • First question is whether you are really running both of these in the same system. You haven't said so. – user207421 Nov 16 '17 at 11:33
  • Second question is what the actual system name(s) and build number(s) are for the system(s) that you are testing on. – Stephen C Nov 16 '17 at 11:47
  • I ran above test in same local UAT system but at the client side, they are using Java 1.6-31 update it's a client-server communication whereas I can update in server side but in client side, I cannot. – naveen Nov 17 '17 at 03:33

1 Answers1

0

Think about movie, "back to the future".

If you went back in time to 1800s with a DeLorean, people of that time would call it "a wagon" because it is what they call a cart on 4 wheels, although they would be puzzled a bit because they would not see any horses in front the vehicle.

If you went to 2500s with the same car, people would probably call it "a vintage car out of the past".

So it is all relative.

The versions of Java, you are using are both outdated. They are trying to name your operating system as best as they can. It is understandable that they fail in precision but we should still applaud their effort to give you a "close enough" description.

EDIT:

Because there was a bug in JDK, which was fixed by this

More info could be found this topic could also be found here

Alp
  • 3,027
  • 1
  • 13
  • 28
  • I understood on OS name @alp but why version number also different, because I cannot change on the client side. – naveen Nov 17 '17 at 03:34