I think It's a best approach to use Apache lang dependency to decide which OS you're running programmatically through Java
import org.apache.commons.lang3.SystemUtils;
public class App {
public static void main( String[] args ) {
if(SystemUtils.IS_OS_WINDOWS_7)
System.out.println("It's a Windows 7 OS");
if(SystemUtils.IS_OS_WINDOWS_8)
System.out.println("It's a Windows 8 OS");
if(SystemUtils.IS_OS_LINUX)
System.out.println("It's a Linux OS");
if(SystemUtils.IS_OS_MAC)
System.out.println("It's a MAC OS");
}
}