1 28 29 package org.objectweb.common; 30 31 35 public class Env { 36 37 40 private Env() { 41 42 } 43 44 public static final int JAVA_1_1_6 = 116; 46 47 public static final int JAVA_1_1_7 = 117; 48 49 public static final int JAVA_1_1_8 = 118; 50 51 public static final int JAVA_1_2 = 120; 52 53 public static final int JAVA_1_3 = 130; 54 55 public static final int JAVA_1_4 = 140; 56 57 private static int javaVersion = -1; 58 59 62 public static boolean isOsWindows() { 63 String osName = System.getProperty("os.name", ""); 64 return (osName.startsWith("Windows")); 65 } 66 67 70 public static boolean isOsMacOsX() { 71 String osName = System.getProperty("os.name", ""); 72 return (osName.startsWith("Mac OS X")); 73 } 74 75 79 public static int getJavaVersion() { 80 81 if (javaVersion == -1) { 82 String strjv = System.getProperty("java.version", ""); 84 if (strjv.indexOf("1.1.6") == 0) { 85 javaVersion = JAVA_1_1_6; 86 } 87 if (strjv.indexOf("1.1.7") == 0) { 88 javaVersion = JAVA_1_1_7; 89 } 90 if (strjv.indexOf("1.1.8") == 0) { 91 javaVersion = JAVA_1_1_8; 92 } 93 if (strjv.indexOf("1.2") == 0) { 94 javaVersion = JAVA_1_2; 95 } 96 if (strjv.indexOf("1.3") == 0) { 97 javaVersion = JAVA_1_3; 98 } 99 if (strjv.indexOf("1.4") == 0) { 100 javaVersion = JAVA_1_4; 101 } 102 } 103 return javaVersion; 104 } 105 106 109 public static boolean isJAVA2() { 110 return (getJavaVersion() >= JAVA_1_2); 111 } 112 113 116 public static boolean isJAVA4() { 117 return (getJavaVersion() >= JAVA_1_4); 118 } 119 } 120 121 | Popular Tags |