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
No comments:
Post a Comment