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