public class JavaVersion
extends java.lang.Object
Parses java versions to extract a consistent set of version parts
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
JAVA_TARGET_PLATFORM
Context attribute that can be set to target a different version of the jvm than the current runtime.
|
private int |
major |
private int |
micro |
private int |
minor |
private int |
platform |
private java.lang.String |
version |
static JavaVersion |
VERSION |
Modifier | Constructor and Description |
---|---|
private |
JavaVersion(java.lang.String version,
int platform,
int major,
int minor,
int micro) |
Modifier and Type | Method and Description |
---|---|
int |
getMajor()
Returns the major number version, such as
1 for JDK 1.8.0_92 and 9 for JDK 9.2.4. |
int |
getMicro()
Returns the micro number version (aka security number), such as
0 for JDK 1.8.0_92 and 4 for JDK 9.2.4. |
int |
getMinor()
Returns the minor number version, such as
8 for JDK 1.8.0_92 and 2 for JDK 9.2.4. |
int |
getPlatform()
Returns the Java Platform version, such as
8 for JDK 1.8.0_92 and 9 for JDK 9.2.4. |
java.lang.String |
getSuffix()
Deprecated.
|
int |
getUpdate()
Deprecated.
|
java.lang.String |
getVersion() |
static JavaVersion |
parse(java.lang.String v) |
java.lang.String |
toString() |
public static final java.lang.String JAVA_TARGET_PLATFORM
public static final JavaVersion VERSION
private final java.lang.String version
private final int platform
private final int major
private final int minor
private final int micro
private JavaVersion(java.lang.String version, int platform, int major, int minor, int micro)
public static JavaVersion parse(java.lang.String v)
public java.lang.String getVersion()
public int getPlatform()
Returns the Java Platform version, such as 8
for JDK 1.8.0_92 and 9
for JDK 9.2.4.
public int getMajor()
Returns the major number version, such as 1
for JDK 1.8.0_92 and 9
for JDK 9.2.4.
public int getMinor()
Returns the minor number version, such as 8
for JDK 1.8.0_92 and 2
for JDK 9.2.4.
public int getMicro()
Returns the micro number version (aka security number), such as 0
for JDK 1.8.0_92 and 4
for JDK 9.2.4.
@Deprecated public int getUpdate()
Returns the update number version, such as 92
for JDK 1.8.0_92 and 0
for JDK 9.2.4.
@Deprecated public java.lang.String getSuffix()
Returns the remaining string after the version numbers, such as -internal
for
JDK 1.8.0_92-internal and -ea
for JDK 9-ea, or +13
for JDK 9.2.4+13.
public java.lang.String toString()
toString
in class java.lang.Object