Actually, Processing is doing it in a similar (but more robust) way:
- String osname = System.getProperty("os.name");
- if (osname.indexOf("Mac") != -1) {
- platform = MACOSX;
- } else if (osname.indexOf("Windows") != -1) {
- platform = WINDOWS;
- } else if (osname.equals("Linux")) { // true for the ibm vm
- platform = LINUX;
- } else {
- platform = OTHER;
- }
These constants are integers, so you just check them with switch or if platform == XXX