Sunday 6 March 2022

Check whether my application is running on windows system or not

Below snippet return true, if the application is running on windows, else false.

public static boolean isWindows() {
    String operatingSystemName = System.getProperty("os.name");
    return operatingSystemName.toLowerCase().startsWith("windows");
}

 

AppEnvironment.java

package com.sample.app.env;

public class AppEnvironment {
    public static boolean isWindows() {
        String operatingSystemName = System.getProperty("os.name");
        return operatingSystemName.toLowerCase().startsWith("windows");
    }
    
    public static void main(String[] args) {
        System.out.println("Is Applicaiton running on windows ? " + isWindows());
    }

}

 


You may like

Miscellaneous

Implement command line progress bar

No comments:

Post a Comment