I understand that you can do
SystemUtils.IS_OS_WINDOWS_VISTA || SystemUtils.IS_OS_WINDOWS_7
but is there a way to do this programatically for all future versions windows, so that the method is something like:
isWindowsVistaOrHigher()
I understand that you can do
SystemUtils.IS_OS_WINDOWS_VISTA || SystemUtils.IS_OS_WINDOWS_7
but is there a way to do this programatically for all future versions windows, so that the method is something like:
isWindowsVistaOrHigher()
I think you don't need Apache Commons at all. The system property os.version
contains the internal OS version (os.name
is the human-readable name and will contain Windows
followed by more specific info such as Vista
). I think on Windows 7 if you call System.getProperty("os.version")
you will get 6.1
while Vista is 6.0
. Assuming they don't change the convention, you could try to take the part up to the first dot if a dot is present (using String.substring()
and String.indexOf('.')
), parse the substring as an integer using Integer.parseInt()
and compare if the resulting value is at least 6
.
What I ended up doing was:
public boolean isVistaOrHigher()
{
return !SystemUtils.IS_OS_WINDOWS_XP && !SystemUtils.IS_OS_WINDOWS_98 && ... ;
}