Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test for Windows 7 platform?

I have a Java app which needs to run differently when on Windows 7.

How would you check which Windows version is present? Is it enough to check for OS version 6.1?

like image 436
paul Avatar asked Feb 16 '10 12:02

paul


1 Answers

I've solved the same problem checking also for os.name, in a null-safe way:

public boolean runningOnWindows7() {
    String osName = System.getProperty("os.name");
    String osVersion = System.getProperty("os.version");
    return "Windows 7".equals(osName) && "6.1".equals(osVersion);
}
like image 188
dfa Avatar answered Sep 22 '22 10:09

dfa