Home >Java >javaTutorial >What is the new version scheme in Java 9?

What is the new version scheme in Java 9?

WBOY
WBOYforward
2023-09-13 08:05:02936browse

Java 9中的新版本方案是什么?

Since Java 9, versioning can be aligned with Semantic Versioning. The version number can be a sequence of non-empty strings separated by dots . It contains three main parts: Major version number, Minor version number, and Security. The new version control scheme is documented in the Runtime. Version class, and version information can be accessed from it.

The version number format is as follows:

<strong>$MAJOR.$MINOR.$SECURITY(.$otherpart)?</strong>
  • $MAJOR is the major version number, which is incremented when a major version is released that usually changes the platform specification. For JDK 9, the value is 9.
  • $MINOR is the minor version number used for releases that contain bug fixes and enhancements to the standard API.
  • $SECURITY is the security level used for releases that contain critical security fixes. When the minor version number is incremented, this version cannot be reset to zero.
  • $otherpart consists of one or more releases used by the JVM provider to indicate patches with minor non-security fixes.

The version string can be a version number with additional information (such as an early access release identifier or build number):

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

Example

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

Output

<strong>9.0.4+11
9
0
4</strong>

The above is the detailed content of What is the new version scheme in Java 9?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete