Package jenkins.util.java
Class JavaUtils
java.lang.Object
jenkins.util.java.JavaUtils
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class)
public class JavaUtils
extends Object
Utility class for Java environment management and checks.
- Author:
- Oleg Nenashev
-
Method Summary
Modifier and TypeMethodDescriptionstatic io.jenkins.lib.versionnumber.JavaSpecificationVersion
Returns the JVM's current version as aVersionNumber
instance.static String
Returns the JVM's current version as aString
.static boolean
Check whether the current JVM is running with Java 8 or belowstatic boolean
Check whether the current JVM is running with Java 9 or above.
-
Method Details
-
isRunningWithJava8OrBelow
public static boolean isRunningWithJava8OrBelow()Check whether the current JVM is running with Java 8 or below- Returns:
true
if it is Java 8 or older version
-
isRunningWithPostJava8
public static boolean isRunningWithPostJava8()Check whether the current JVM is running with Java 9 or above.- Returns:
true
if it is Java 9 or above
-
getCurrentJavaRuntimeVersionNumber
public static io.jenkins.lib.versionnumber.JavaSpecificationVersion getCurrentJavaRuntimeVersionNumber()Returns the JVM's current version as aVersionNumber
instance. -
getCurrentRuntimeJavaVersion
Returns the JVM's current version as aString
. See JEP 223 for the expected format.- Until Java 8 included, the expected format should be starting with
1.x
- Starting with Java 9, cf. JEP-223 linked above, the version got simplified in 9.x, 10.x, etc.
- See Also:
- Until Java 8 included, the expected format should be starting with
-