Package org.apache.maven.surefire.booter
Class SystemUtils
- java.lang.Object
-
- org.apache.maven.surefire.booter.SystemUtils
-
public final class SystemUtils extends java.lang.ObjectJDK 9 support.- Since:
- 2.20.1
- Author:
- Tibor Digana (tibor17)
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanendsWithJavaPath(java.lang.String jvmExecPath)static booleanisBuiltInJava9AtLeast()static booleanisJava9AtLeast(java.lang.String jvmExecutablePath)static booleanisJava9AtLeast(java.math.BigDecimal version)static java.lang.Longpid()static java.lang.LongpidOf(java.lang.Process process)Returns the OS PID of the given childProcessusing the Java 9+Process.pid()method via reflection.static java.lang.ClassLoaderplatformClassLoader()static java.io.FiletoJdkHomeFromJre()If system propertyjava.homeis/jdk(since jdk9) or/jdk/jre(prior to jdk9) then the absolute path to JDK home is returned/jdk.static java.io.FiletoJdkHomeFromJvmExec(java.lang.String jvmExecutable)IfjvmExecutableis/jdk/bin/java(since jdk9) or/jdk/jre/bin/java(prior to jdk9) then the absolute path to JDK home is returned/jdk.static java.math.BigDecimaltoJdkVersionFromReleaseFile(java.io.File jdkHome)
-
-
-
Method Detail
-
endsWithJavaPath
public static boolean endsWithJavaPath(java.lang.String jvmExecPath)
- Parameters:
jvmExecPath- e.g. /jdk/bin/java, /jdk/jre/bin/java- Returns:
trueifjvmExecPathis path to java binary executor
-
toJdkHomeFromJvmExec
public static java.io.File toJdkHomeFromJvmExec(java.lang.String jvmExecutable)
IfjvmExecutableis/jdk/bin/java(since jdk9) or/jdk/jre/bin/java(prior to jdk9) then the absolute path to JDK home is returned/jdk.
Null is returned ifjvmExecutableis incorrect.- Parameters:
jvmExecutable- /jdk/bin/java* or /jdk/jre/bin/java*- Returns:
- path to jdk directory; or
nullif wrong path or directory layout of JDK installation
-
toJdkHomeFromJre
public static java.io.File toJdkHomeFromJre()
If system propertyjava.homeis/jdk(since jdk9) or/jdk/jre(prior to jdk9) then the absolute path to JDK home is returned/jdk.- Returns:
- path to JDK
-
toJdkVersionFromReleaseFile
public static java.math.BigDecimal toJdkVersionFromReleaseFile(java.io.File jdkHome)
-
isJava9AtLeast
public static boolean isJava9AtLeast(java.lang.String jvmExecutablePath)
-
isBuiltInJava9AtLeast
public static boolean isBuiltInJava9AtLeast()
-
isJava9AtLeast
public static boolean isJava9AtLeast(java.math.BigDecimal version)
-
platformClassLoader
public static java.lang.ClassLoader platformClassLoader()
-
pid
public static java.lang.Long pid()
-
pidOf
public static java.lang.Long pidOf(java.lang.Process process)
Returns the OS PID of the given childProcessusing the Java 9+Process.pid()method via reflection.- Parameters:
process- aProcessreturned byProcessBuilder/Runtime.exec; may benull- Returns:
- the PID, or
nullwhen it cannot be determined (e.g. running on Java 8 or the reflective call fails) - Since:
- 3.6.0
-
-