01: /**
02: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
03: *
04: * Permission is hereby granted, free of charge, to any person obtaining a copy
05: * of this software and associated documentation files (the "Software"), to deal
06: * in the Software without restriction, including without limitation the rights
07: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
08: * copies of the Software, and to permit persons to whom the Software is
09: * furnished to do so, subject to the following conditions:
10: *
11: * The above copyright notice and this permission notice shall be included in
12: * all copies or substantial portions of the Software.
13: *
14: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20: * SOFTWARE.
21: */package com.liferay.portal.kernel.util;
22:
23: import com.liferay.portal.kernel.log.Log;
24: import com.liferay.portal.kernel.log.LogFactoryUtil;
25: import com.liferay.portal.kernel.log.LogUtil;
26:
27: /**
28: * <a href="JavaProps.java.html"><b><i>View Source</i></b></a>
29: *
30: * @author Brian Wing Shun Chan
31: *
32: */
33: public class JavaProps {
34:
35: public static final double JAVA_CLASS_VERSION_JDK_5 = 49.0;
36:
37: public static String getJavaClassPath() {
38: return _instance._javaClassPath;
39: }
40:
41: public static double getJavaClassVersion() {
42: return _instance._javaClassVersion;
43: }
44:
45: public static String getJavaRuntimeVersion() {
46: return _instance._javaRuntimeVersion;
47: }
48:
49: public static double getJavaSpecificationVersion() {
50: return _instance._javaSpecificationVersion;
51: }
52:
53: public static String getJavaVersion() {
54: return _instance._javaVersion;
55: }
56:
57: public static String getJavaVmVersion() {
58: return _instance._javaVmVersion;
59: }
60:
61: public static boolean isJDK5() {
62: if (JavaProps.getJavaClassVersion() >= JavaProps.JAVA_CLASS_VERSION_JDK_5) {
63:
64: return true;
65: } else {
66: return false;
67: }
68: }
69:
70: private JavaProps() {
71: _javaClassPath = System.getProperty("java.class.path");
72: _javaClassVersion = Double.parseDouble(System
73: .getProperty("java.class.version"));
74: _javaRuntimeVersion = System
75: .getProperty("java.runtime.version");
76: _javaSpecificationVersion = Double.parseDouble(System
77: .getProperty("java.specification.version"));
78: _javaVersion = System.getProperty("java.version");
79: _javaVmVersion = System.getProperty("java.vm.version");
80:
81: LogUtil.debug(_log, System.getProperties());
82: }
83:
84: private static Log _log = LogFactoryUtil.getLog(JavaProps.class);
85:
86: private static JavaProps _instance = new JavaProps();
87:
88: private String _javaClassPath;
89: private double _javaClassVersion;
90: private String _javaRuntimeVersion;
91: private double _javaSpecificationVersion;
92: private String _javaVersion;
93: private String _javaVmVersion;
94:
95: }
|