Determine the JDK Version Number : JDK « Development Class « Java

Home
Java
1.2D Graphics GUI
2.3D
3.Advanced Graphics
4.Ant
5.Apache Common
6.Chart
7.Class
8.Collections Data Structure
9.Data Type
10.Database SQL JDBC
11.Design Pattern
12.Development Class
13.EJB3
14.Email
15.Event
16.File Input Output
17.Game
18.Generics
19.GWT
20.Hibernate
21.I18N
22.J2EE
23.J2ME
24.JavaFX
25.JDK 6
26.JDK 7
27.JNDI LDAP
28.JPA
29.JSP
30.JSTL
31.Language Basics
32.Network Protocol
33.PDF RTF
34.Reflection
35.Regular Expressions
36.Scripting
37.Security
38.Servlets
39.Spring
40.Swing Components
41.Swing JFC
42.SWT JFace Eclipse
43.Threads
44.Tiny Application
45.Velocity
46.Web Services SOA
47.XML
Java » Development Class » JDK 




Determine the JDK Version Number
  


/** Determine the JDK Version Number
 *
 * There is a human readible JDK version number available as a Java property. The property name is called "java.version".
 * Unfortunately it is complicated to parse it mechanically. A somewhat better choice is the Java property called
 * "java.class.version". The property value can be converted to a floating pointer value. JDK 1.1 implies 45.3. JDK 1.2
 * implies 46.0. JDK 1.3 implies 47.0. JDK 1.4 implies 48.0.
 * <p>
 * java.class.version property value
 * <ul>
 * <li> JDK 1.1 = 45.3
 * <li> JDK 1.2 = 46.0
 * <li> JDK 1.3 = 47.0
 * <li> JDK 1.4 = 48.0
 * </ul>
 *
 @author Thomas Rischbeck <[email protected]>
 @version $Id: VersionCheck.java 2342 2006-03-30 13:06:17Z  $
 */

public class VersionCheck {

   private static final String CLASS_VERSION = System.getProperty("java.class.version","44.0");
   private static final boolean IS_JDK_11 = ("46.0".compareTo(CLASS_VERSION0&& ("45.3".compareTo(CLASS_VERSION<= 0);
   private static final boolean IS_JDK_12 = ("47.0".compareTo(CLASS_VERSION0&& ("46.0".compareTo(CLASS_VERSION<= 0);
   private static final boolean IS_JDK_13 = ("48.0".compareTo(CLASS_VERSION0&& ("47.0".compareTo(CLASS_VERSION<= 0);
   private static final boolean IS_JDK_14 = ("49.0".compareTo(CLASS_VERSION0&& ("48.0".compareTo(CLASS_VERSION<= 0);
   private static final boolean IS_JDK_13_OR_BELOW = IS_JDK_11 || IS_JDK_12 || IS_JDK_13;
   private static final boolean IS_JDK_14_OR_ABOVE = ("48.0".compareTo(CLASS_VERSION<= 0);


   public static final boolean isJDK11only()
   {
     return IS_JDK_11;
   }

   public static final boolean isJDK12only()
   {
     return IS_JDK_12;
   }

   public static final boolean isJDK13only()
   {
     return IS_JDK_13;
   }

   public static final boolean isJDK14only()
   {
     return IS_JDK_14;
   }

   public static final boolean isJDK13orBelow()
   {
      return IS_JDK_13_OR_BELOW;
   }

   public static final boolean isJDK14orAbove()
   {
      return IS_JDK_14_OR_ABOVE;
   }

}

   
    
  














Related examples in the same category
1.Provides common access to specifics about the version of Java that a virtual machine supports.
2.Deals with the different version of the Java Virtual Machine.
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.