1   /**
2    * Copyright (c) 2000-2007 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * 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   */
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  /**
30   * <a href="JavaProps.java.html"><b><i>View Source</i></b></a>
31   *
32   * @author Brian Wing Shun Chan
33   *
34   */
35  public class JavaProps {
36  
37      public static final double JAVA_CLASS_VERSION_JDK_5 = 49.0;
38  
39      public static String getJavaClassPath() {
40          return _instance._javaClassPath;
41      }
42  
43      public static double getJavaClassVersion() {
44          return _instance._javaClassVersion;
45      }
46  
47      public static String getJavaRuntimeVersion() {
48          return _instance._javaRuntimeVersion;
49      }
50  
51      public static double getJavaSpecificationVersion() {
52          return _instance._javaSpecificationVersion;
53      }
54  
55      public static String getJavaVersion() {
56          return _instance._javaVersion;
57      }
58  
59      public static String getJavaVmVersion() {
60          return _instance._javaVmVersion;
61      }
62  
63      public static boolean isJDK5() {
64          if (JavaProps.getJavaClassVersion() >=
65                  JavaProps.JAVA_CLASS_VERSION_JDK_5) {
66  
67              return true;
68          }
69          else {
70              return false;
71          }
72      }
73  
74      private JavaProps() {
75          _javaClassPath = System.getProperty("java.class.path");
76          _javaClassVersion = Double.parseDouble(System.getProperty(
77              "java.class.version"));
78          _javaRuntimeVersion = System.getProperty("java.runtime.version");
79          _javaSpecificationVersion = Double.parseDouble(System.getProperty(
80              "java.specification.version"));
81          _javaVersion = System.getProperty("java.version");
82          _javaVmVersion = System.getProperty("java.vm.version");
83  
84          LogUtil.debug(_log, System.getProperties());
85      }
86  
87      private static Log _log = LogFactoryUtil.getLog(JavaProps.class);
88  
89      private static JavaProps _instance = new JavaProps();
90  
91      private String _javaClassPath;
92      private double _javaClassVersion;
93      private String _javaRuntimeVersion;
94      private double _javaSpecificationVersion;
95      private String _javaVersion;
96      private String _javaVmVersion;
97  
98  }