1
22
23 package com.liferay.portal.kernel.util;
24
25 import com.liferay.portal.kernel.log.Log;
26 import com.liferay.portal.kernel.log.LogFactoryUtil;
27 import com.liferay.portal.kernel.log.LogUtil;
28
29
35 public class JavaProps {
36
37 public static final double JAVA_CLASS_VERSION_JDK_4 = 48.0;
38
39 public static final double JAVA_CLASS_VERSION_JDK_5 = 49.0;
40
41 public static final double JAVA_CLASS_VERSION_JDK_6 = 50.0;
42
43 public static final double JAVA_CLASS_VERSION_JDK_7 = 51.0;
44
45 public static String getJavaClassPath() {
46 return _instance._javaClassPath;
47 }
48
49 public static double getJavaClassVersion() {
50 return _instance._javaClassVersion;
51 }
52
53 public static String getJavaRuntimeVersion() {
54 return _instance._javaRuntimeVersion;
55 }
56
57 public static double getJavaSpecificationVersion() {
58 return _instance._javaSpecificationVersion;
59 }
60
61 public static String getJavaVersion() {
62 return _instance._javaVersion;
63 }
64
65 public static String getJavaVmVersion() {
66 return _instance._javaVmVersion;
67 }
68
69 public static boolean isJDK4() {
70 if (JavaProps.getJavaClassVersion() >=
71 JavaProps.JAVA_CLASS_VERSION_JDK_4) {
72
73 return true;
74 }
75 else {
76 return false;
77 }
78 }
79
80 public static boolean isJDK5() {
81 if (JavaProps.getJavaClassVersion() >=
82 JavaProps.JAVA_CLASS_VERSION_JDK_5) {
83
84 return true;
85 }
86 else {
87 return false;
88 }
89 }
90
91 public static boolean isJDK6() {
92 if (JavaProps.getJavaClassVersion() >=
93 JavaProps.JAVA_CLASS_VERSION_JDK_6) {
94
95 return true;
96 }
97 else {
98 return false;
99 }
100 }
101
102 public static boolean isJDK7() {
103 if (JavaProps.getJavaClassVersion() >=
104 JavaProps.JAVA_CLASS_VERSION_JDK_7) {
105
106 return true;
107 }
108 else {
109 return false;
110 }
111 }
112
113 private JavaProps() {
114 _javaClassPath = System.getProperty("java.class.path");
115 _javaClassVersion = Double.parseDouble(System.getProperty(
116 "java.class.version"));
117 _javaRuntimeVersion = System.getProperty("java.runtime.version");
118 _javaSpecificationVersion = Double.parseDouble(System.getProperty(
119 "java.specification.version"));
120 _javaVersion = System.getProperty("java.version");
121 _javaVmVersion = System.getProperty("java.vm.version");
122
123 LogUtil.debug(_log, System.getProperties());
124 }
125
126 private static Log _log = LogFactoryUtil.getLog(JavaProps.class);
127
128 private static JavaProps _instance = new JavaProps();
129
130 private String _javaClassPath;
131 private double _javaClassVersion;
132 private String _javaRuntimeVersion;
133 private double _javaSpecificationVersion;
134 private String _javaVersion;
135 private String _javaVmVersion;
136
137 }