File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes System.getProperty( Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "System.getProperty("") and compatibility modes with new Windows OS Watch "System.getProperty("") and compatibility modes with new Windows OS New topic

System.getProperty("") and compatibility modes with new Windows OS's

Jeff Baer

Joined: Jul 01, 2010
Posts: 3
We have a java app that is installed on different Windows platforms, and we've been using System.getProperty("") for a long time to determine the OS the app is running under. We use this info to track how many installations we have under each Windows platform. Also, our app is packaged as an executable via InstallAnywhere.

With the newer versions of Windows (Vista, Windows 7, Windows Server 2008), we're usually getting the correct OS name back... so if it's installed under Windows 7 we're getting "Windows 7" back. However, under these new OSes, a user can set the "compatibility mode" to an older OS such as Windows XP. We're finding that the "" property is coming back as whatever OS is selected for this compatibility mode. For example, if the application is installed to Windows 7, but the executable's compatibility mode is set to Windows XP, then the call to System.getProperty("") is returning "Windows XP".

Does anyone know if there's a way to get the real OS? We're tossing around the idea of making an external system call or running another executable that writes the real OS name to a temporary file we can then read... but that's not foolproof either since someone can set the compatibility mode for that executable as well.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15081

Welcome to JavaRanch.

I don't think there is a pure-Java solution to this, since the problem is very Windows-specific. Creating a native executable that does Windows system calls and somehow finds out what the real operating system is sounds like something you could do. But you're really trying to work against the intention of Windows compatibility mode - the whole idea is ofcourse to make the app think that it works on an older Windows version.

Ultimately, the question is how well you trust your users. Do you really have users that deliberately want to trick you by making the software run in compatibility mode (what motives would they have to make you think they're running Windows XP?). Are there really that many users running your software in compatibility mode (what would be their reason to make it run in compatibility mode?) so that it seriously affects your statistics?

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
I agree. Here's the link:
subject: System.getProperty("") and compatibility modes with new Windows OS's
It's not a secret anymore!