David Arno
David Arno

Reputation: 43254

Why is Java on a Vista box reporting it is on XP?

I have stumbled across something truly puzzling regarding System.getProperty("os.name"). According to a Java bug on the matter and the Java 5 release notes (search for "os.name"), there was a bug in Java with early "longhorn" versions of Vista that should have been fixed in v5 release 10.

However on my Vista SP1 box - using both v5 release 15 and v6 release 6 - System.getProperty("os.name") returns "Windows XP". Further System.getProperty("os.version") returns "5.1". I cannot find anything relating to this issue via Google though. This makes me wonder whether it is something odd with my Vista setup. I have tried calling the GetVersionEx() API function from a test C program and it returns major version 6, minor 0 (as I'd expect for a Vista install).

Has anyone else encountered this problem, know of a fix or have any suggestions of how I might work around it without using JNI?

Upvotes: 5

Views: 1000

Answers (2)

Martin v. Löwis
Martin v. Löwis

Reputation: 127467

It might be that Java runs in XP compatibility mode. In that case, Vista will fake the windows version number, making Java believe that it runs on XP. Check the compatibility tab of the executable.

Upvotes: 10

nsayer
nsayer

Reputation: 17047

The actual windows version number of Windows 2000 was 5.0. Windows XP was 5.1. Vista is supposedly 6.0, so your test program is functioning correctly. It sounds to me like Java is definitely getting this wrong.

You might have to rely on a JNI to get the right answer. I sort of assume that you've already asked yourself why you might need to vary the behavior of your program based on whether you're using XP or Vista.

Upvotes: 0

Related Questions