package ie.dcu.util;
/**
* Utilities for identifying the operating system.
*
* @author Kevin McGuinness
*/
public class OsUtils {
private static final String OS_NAME = "os.name";
/**
* Returns true if the is Mac OS or Mac OS X.
*/
public static boolean isMacOS() {
String os = System.getProperty("os.name");
os = os.toLowerCase();
return os.startsWith("mac os");
}
/**
* Returns true if the OS is Mac OS X.
*/
public static boolean isMacOSX() {
String os = System.getProperty(OS_NAME);
os = os.toLowerCase();
return os.startsWith("mac os x");
}
/**
* Returns true if the OS is an MS Windows variant.
*/
public static boolean isWindows() {
String os = System.getProperty(OS_NAME);
return os.startsWith("Windows");
}
/**
* Returns true if the OS is a Linux variant.
*/
public static boolean isLinux() {
String os = System.getProperty(OS_NAME);
return os.startsWith("Linux");
}
/**
* Returns the users home folder.
*/
public static String userHome() {
return System.getProperty("user.home");
}
/**
* Returns true if we are on Linux and on a 64 bit Java VM.
*
* Note: this is basically guess-work and depends on the VM vendor.
* Should work for Sun Java though.
*/
public static boolean isLinux64() {
return isLinux() && System.getProperty("os.arch").endsWith("64");
}
}