public final class JavaVersion extends java.lang.Object implements java.lang.Comparable<JavaVersion>
Modifier and Type | Field and Description |
---|---|
int |
build
The build number.
|
boolean |
ea
true if the platform is an early access release, false otherwise (or when not known). |
int |
feature
The major version.
|
int |
minor
The minor version.
|
int |
update
The patch version.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(JavaVersion o) |
static JavaVersion |
compose(int feature) |
static JavaVersion |
compose(int feature,
int minor,
int update,
int build,
boolean ea)
Composes a version object out of given parameters.
|
static JavaVersion |
current()
Returns the version of a Java runtime the class is loaded into.
|
boolean |
equals(java.lang.Object o) |
int |
hashCode() |
boolean |
isAtLeast(int feature) |
static JavaVersion |
parse(java.lang.String versionString)
Parses a Java version string.
|
java.lang.String |
toFeatureMinorUpdateString() |
java.lang.String |
toFeatureString() |
java.lang.String |
toString() |
static JavaVersion |
tryParse(java.lang.String versionString)
A safe version of
parse(String) - returns null if can't parse a version string. |
public final int feature
public final int minor
0
.public final int update
public final int build
public final boolean ea
true
if the platform is an early access release, false
otherwise (or when not known).public int compareTo(JavaVersion o)
compareTo
in interface java.lang.Comparable<JavaVersion>
public boolean isAtLeast(int feature)
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toFeatureString()
public java.lang.String toFeatureMinorUpdateString()
public java.lang.String toString()
toString
in class java.lang.Object
public static JavaVersion compose(int feature, int minor, int update, int build, boolean ea) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- when any of numbers is negativepublic static JavaVersion compose(int feature)
public static JavaVersion current()
public static JavaVersion parse(java.lang.String versionString) throws java.lang.IllegalArgumentException
Parses a Java version string.
Supports various sources, including (but not limited to):
- "java.*version"
system properties (a version number without any decoration)
- values of Java compiler -source/-target/--release options ("$MAJOR", "1.$MAJOR")
- output of "java -version
" (usually "java version \"$VERSION\"")
- a second line of the above command (something like to "Java(TM) SE Runtime Environment (build $VERSION)")
- output of "java --full-version
" ("java $VERSION")
- a line of "release" file ("JAVA_VERSION=\"$VERSION\"")
See com.intellij.util.lang.JavaVersionTest for examples.
java.lang.IllegalArgumentException
- if failed to recognize the number.public static JavaVersion tryParse(java.lang.String versionString)
parse(String)
- returns null
if can't parse a version string.