01: /*
02: This file is part of LayoutHelper - Utilities for LayoutManagment
03: Copyright (c) 2004 Patrick Gotthardt
04:
05: This program is free software; you can redistribute it and/or
06: modify it under the terms of the GNU General Public License
07: as published by the Free Software Foundation; either version 2
08: of the License, or any later version.
09:
10: This program is distributed in the hope that it will be useful,
11: but WITHOUT ANY WARRANTY; without even the implied warranty of
12: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13: GNU General Public License for more details.
14:
15: You should have received a copy of the GNU General Public License
16: along with this program; if not, write to the Free Software
17: Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18: */
19: package com.pagosoft;
20:
21: import java.io.File;
22:
23: public class OS {
24: private static boolean isMacOsX = false;
25:
26: private static boolean isWindows = false;
27:
28: private static boolean isWindowsXP = false;
29:
30: private static boolean isUnix = false;
31:
32: private static boolean isJava14 = false;
33:
34: private static boolean isJava15 = false;
35:
36: static {
37: // Current Java version:
38: String javaVersion = System.getProperty("java.version");
39: isJava14 = (javaVersion.compareTo("1.4") >= 0);
40: isJava15 = (javaVersion.compareTo("1.5") >= 0);
41:
42: /*
43: * if(System.getProperty("mrj.version") != null) { isMacOsX = true; }
44: * else {
45: */
46: String os = System.getProperty("os.name").toLowerCase();
47: // http://developer.apple.com/technotes/tn2002/tn2110.html#PARTONE
48: if (os.startsWith("mac os x")) {
49: isMacOsX = true;
50: } else {
51: isWindows = os.indexOf("windows") != -1;
52: if (isWindows) {
53: isWindowsXP = os.indexOf("windows xp") != -1;
54: } else {
55: isUnix = File.separatorChar == '/';
56: }
57: }
58: // }
59: }
60:
61: public static boolean isWindows() {
62: return isWindows;
63: }
64:
65: public static boolean isWindowsXP() {
66: return isWindowsXP;
67: }
68:
69: public static boolean isMacOsX() {
70: return isMacOsX;
71: }
72:
73: public static boolean isUnix() {
74: return isUnix;
75: }
76:
77: public static boolean isJava15() {
78: return isJava15;
79: }
80:
81: public static boolean isJava14() {
82: return isJava14;
83: }
84: }
|