What is New Versioning Scheme in Java 9?


Since Java 9, versioning can be consistent with semantic versioning. The version number can be a non-empty sequence of strings separated by dots. It contains three major parts: major version number, minor version number, and security. The new versioning scheme has documented in Runtime. Version class and version information can be accessed from it.

The version numbers have the below format:

$MAJOR.$MINOR.$SECURITY(.$otherpart)?
  • $MAJOR is the major version number and incremented when a major version has released that typically changes the platform specification. For JDK 9, this value is 9.
  • $MINOR is the minor version number and incremented for releases that contain bug fixes and enhancements to standard APIs.
  • $SECURITY is the security level and incremented for releases that contain critical security fixes. This version can't reset to zero when a minor version number has incremented.
  • $otherpart consists of one or more versions that have been used by JVM providers to indicate a patch with a small number of non-security fixes.

The version string can be a version number with some other information such as early-access release identifier or the build number:

$VNUM(-$PRE)?\+$BUILD(-$OPT)?
$VNUM-$PRE(-$OPT)?
$VNUM(+-$OPT)?
  • $PRE is a pre-release identifier.
  • $BUILD is the build number.
  • $OPT is optional information such as a timestamp.

Example

public class VersionSchemeTest {
   public static void main(String args[]) {
      System.out.println(Runtime.version().toString());  // String representation of the version  
      System.out.println(Runtime.version().major());  // major version number
      System.out.println(Runtime.version().minor());  // minor version number
      System.out.println(Runtime.version().security());  // security version number
   }
}

Output

9.0.4+11
9
0
4

Updated on: 12-Mar-2020

507 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements