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