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 is64bit() {
063 return _instance._64bit;
064 }
065
066 public static boolean isIBM() {
067 return _instance._ibm;
068 }
069
070 public static boolean isJDK4() {
071 if (JavaProps.getJavaClassVersion() >=
072 JavaProps.JAVA_CLASS_VERSION_JDK_4) {
073
074 return true;
075 }
076 else {
077 return false;
078 }
079 }
080
081 public static boolean isJDK5() {
082 if (JavaProps.getJavaClassVersion() >=
083 JavaProps.JAVA_CLASS_VERSION_JDK_5) {
084
085 return true;
086 }
087 else {
088 return false;
089 }
090 }
091
092 public static boolean isJDK6() {
093 if (JavaProps.getJavaClassVersion() >=
094 JavaProps.JAVA_CLASS_VERSION_JDK_6) {
095
096 return true;
097 }
098 else {
099 return false;
100 }
101 }
102
103 public static boolean isJDK7() {
104 if (JavaProps.getJavaClassVersion() >=
105 JavaProps.JAVA_CLASS_VERSION_JDK_7) {
106
107 return true;
108 }
109 else {
110 return false;
111 }
112 }
113
114 private JavaProps() {
115 _javaClassPath = System.getProperty("java.class.path");
116 _javaClassVersion = Double.parseDouble(System.getProperty(
117 "java.class.version"));
118 _javaRuntimeVersion = System.getProperty("java.runtime.version");
119 _javaSpecificationVersion = Double.parseDouble(System.getProperty(
120 "java.specification.version"));
121 _javaVendor = System.getProperty("java.vendor");
122 _javaVersion = System.getProperty("java.version");
123 _javaVmVersion = System.getProperty("java.vm.version");
124
125 _64bit = Validator.equals(
126 "64", System.getProperty("sun.arch.data.model"));
127
128 if (_javaVendor != null) {
129 _ibm = _javaVendor.startsWith("IBM");
130 }
131
132 LogUtil.debug(_log, System.getProperties());
133 }
134
135 private static Log _log = LogFactoryUtil.getLog(JavaProps.class);
136
137 private static JavaProps _instance = new JavaProps();
138
139 private boolean _64bit;
140 private boolean _ibm;
141 private String _javaClassPath;
142 private double _javaClassVersion;
143 private String _javaRuntimeVersion;
144 private double _javaSpecificationVersion;
145 private String _javaVendor;
146 private String _javaVersion;
147 private String _javaVmVersion;
148
149 }