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.JDK 6
25.JNDI LDAP
26.JPA
27.JSP
28.JSTL
29.Language Basics
30.Network Protocol
31.PDF RTF
32.Reflection
33.Regular Expressions
34.Scripting
35.Security
36.Servlets
37.Spring
38.Swing Components
39.Swing JFC
40.SWT JFace Eclipse
41.Threads
42.Tiny Application
43.Velocity
44.Web Services SOA
45.XML
Java » Development Class » JDKScreenshots 
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.