This question already has an answer here:
I am seeking to run a common Java program in both Windows and Linux.
The program needs to do some things differently on each platform.
So how can / should my Java program detect it is running under Linux vs. Windows?
Useful simple class are forked by me on: https://gist.github.com/kiuz/816e24aa787c2d102dd0
I think It's a best approach to use Apache lang dependency to decide which OS you're running programmatically through Java
apache commons lang has a class SystemUtils.java you can use :
You can use "system.properties.os", for example:
Here are more details:
Try:
http://docs.oracle.com/javase/7/docs/api/java/lang/System.html#getProperties%28%29