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