Sunday, January 20, 2008

How to check the operating system type and architecture

even if java is superportable (:]), more than often we need to execute operating dependent stuff. The rcp environment helps a lot in this:


if (Platform.getOS().equals(Platform.OS_WIN32)) {
// do windows specific stuff
}else if (Platform.getOS().equals(Platform.OS_LINUX)) {
// do linux specific stuff
}else if (Platform.getOS().equals(Platform.OS_MACOSX)) {
// do macosx specific stuff
}else{
// throw exceptions
}

No comments: