001
014
015 package com.liferay.portal.kernel.util;
016
017 import com.liferay.portal.kernel.log.Log;
018 import com.liferay.portal.kernel.log.LogFactoryUtil;
019 import com.liferay.portal.kernel.log.LogUtil;
020
021
024 public class JavaProps {
025
026 public static final double JAVA_CLASS_VERSION_JDK_4 = 48.0;
027
028 public static final double JAVA_CLASS_VERSION_JDK_5 = 49.0;
029
030 public static final double JAVA_CLASS_VERSION_JDK_6 = 50.0;
031
032 public static final double JAVA_CLASS_VERSION_JDK_7 = 51.0;
033
034 public static String getJavaClassPath() {
035 return _instance._javaClassPath;
036 }
037
038 public static double getJavaClassVersion() {
039 return _instance._javaClassVersion;
040 }
041
042 public static String getJavaRuntimeVersion() {
043 return _instance._javaRuntimeVersion;
044 }
045
046 public static double getJavaSpecificationVersion() {
047 return _instance._javaSpecificationVersion;
048 }
049
050 public static String getJavaVendor() {
051 return _instance._javaVendor;
052 }
053
054 public static String getJavaVersion() {
055 return _instance._javaVersion;
056 }
057
058 public static String getJavaVmVersion() {
059 return _instance._javaVmVersion;
060 }
061
062 public static boolean hasSunBug6291034() {
063 return _instance._sunBug6291034;
064 }
065
066 public static boolean is64bit() {
067 return _instance._64bit;
068 }
069
070 public static boolean isIBM() {
071 return _instance._ibm;
072 }
073
074 public static boolean isJDK4() {
075 if (JavaProps.getJavaClassVersion() >=
076 JavaProps.JAVA_CLASS_VERSION_JDK_4) {
077
078 return true;
079 }
080 else {
081 return false;
082 }
083 }
084
085 public static boolean isJDK5() {
086 if (JavaProps.getJavaClassVersion() >=
087 JavaProps.JAVA_CLASS_VERSION_JDK_5) {
088
089 return true;
090 }
091 else {
092 return false;
093 }
094 }
095
096 public static boolean isJDK6() {
097 if (JavaProps.getJavaClassVersion() >=
098 JavaProps.JAVA_CLASS_VERSION_JDK_6) {
099
100 return true;
101 }
102 else {
103 return false;
104 }
105 }
106
107 public static boolean isJDK7() {
108 if (JavaProps.getJavaClassVersion() >=
109 JavaProps.JAVA_CLASS_VERSION_JDK_7) {
110
111 return true;
112 }
113 else {
114 return false;
115 }
116 }
117
118 private JavaProps() {
119 _javaClassPath = System.getProperty("java.class.path");
120 _javaClassVersion = Double.parseDouble(System.getProperty(
121 "java.class.version"));
122 _javaRuntimeVersion = System.getProperty("java.runtime.version");
123 _javaSpecificationVersion = Double.parseDouble(System.getProperty(
124 "java.specification.version"));
125 _javaVendor = System.getProperty("java.vendor");
126 _javaVersion = System.getProperty("java.version");
127 _javaVmVersion = System.getProperty("java.vm.version");
128
129 _64bit = Validator.equals(
130 "64", System.getProperty("sun.arch.data.model"));
131
132 if (_javaVendor != null) {
133 _ibm = _javaVendor.startsWith("IBM");
134 }
135
136 LogUtil.debug(_log, System.getProperties());
137
138 if (_javaVersion.compareTo("1.5.0_06-") < 0) {
139 _sunBug6291034 = true;
140 }
141 }
142
143 private static Log _log = LogFactoryUtil.getLog(JavaProps.class);
144
145 private static JavaProps _instance = new JavaProps();
146
147 private boolean _64bit;
148 private boolean _ibm;
149 private String _javaClassPath;
150 private double _javaClassVersion;
151 private String _javaRuntimeVersion;
152 private double _javaSpecificationVersion;
153 private String _javaVendor;
154 private String _javaVersion;
155 private String _javaVmVersion;
156 private boolean _sunBug6291034;
157
158 }