The Apache Commons Lang library could help you to determine the running OS type. Here is an simple example.
pom.xml
... <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.1</version> </dependency> ...
So now you could determine the OS by
...
import org.apache.commons.lang3.SystemUtils;
...
if (SystemUtils.IS_OS_WINDOWS) {
System.out.println("This is a WINDOWS OS.");
} else if (SystemUtils.IS_OS_MAC) {
System.out.println("This is a MAC OS.");
} else if (SystemUtils.IS_OS_LINUX) {
System.out.println("This is a LINUX OS.");
} else {
System.out.println("This is a SPECIAL OS.");
}
...
Done =)
Reference:
