00001
00029 package org.objectweb.common;
00030
00035 public class Env {
00036
00040 private Env() {
00041
00042 }
00043
00044
00045 public static final int JAVA_1_1_6 = 116;
00046
00047 public static final int JAVA_1_1_7 = 117;
00048
00049 public static final int JAVA_1_1_8 = 118;
00050
00051 public static final int JAVA_1_2 = 120;
00052
00053 public static final int JAVA_1_3 = 130;
00054
00055 public static final int JAVA_1_4 = 140;
00056
00057 private static int javaVersion = -1;
00058
00062 public static boolean isOsWindows() {
00063 String osName = System.getProperty("os.name", "");
00064 return (osName.startsWith("Windows"));
00065 }
00066
00070 public static boolean isOsMacOsX() {
00071 String osName = System.getProperty("os.name", "");
00072 return (osName.startsWith("Mac OS X"));
00073 }
00074
00079 public static int getJavaVersion() {
00080
00081 if (javaVersion == -1) {
00082
00083 String strjv = System.getProperty("java.version", "");
00084 if (strjv.indexOf("1.1.6") == 0) {
00085 javaVersion = JAVA_1_1_6;
00086 }
00087 if (strjv.indexOf("1.1.7") == 0) {
00088 javaVersion = JAVA_1_1_7;
00089 }
00090 if (strjv.indexOf("1.1.8") == 0) {
00091 javaVersion = JAVA_1_1_8;
00092 }
00093 if (strjv.indexOf("1.2") == 0) {
00094 javaVersion = JAVA_1_2;
00095 }
00096 if (strjv.indexOf("1.3") == 0) {
00097 javaVersion = JAVA_1_3;
00098 }
00099 if (strjv.indexOf("1.4") == 0) {
00100 javaVersion = JAVA_1_4;
00101 }
00102 }
00103 return javaVersion;
00104 }
00105
00109 public static boolean isJAVA2() {
00110 return (getJavaVersion() >= JAVA_1_2);
00111 }
00112
00116 public static boolean isJAVA4() {
00117 return (getJavaVersion() >= JAVA_1_4);
00118 }
00119 }
00120