List of usage examples for java.lang ProcessHandle current
public static ProcessHandle current()
From source file:platform.tooling.support.Runner.java
private Path getCurrentJdkHome() { Path executable = ProcessHandle.current().info().command().map(Paths::get).orElse(null); if (executable != null && executable.getNameCount() > 2) { // noinspection ConstantConditions -- count is 3 or higher: "<JDK_HOME>/bin/java[.exe]" return executable.getParent().getParent().toAbsolutePath(); }/*from www . j a v a 2 s . co m*/ String jdkHome = System.getenv("JDK_HOME"); if (jdkHome != null) { return Paths.get(jdkHome).toAbsolutePath(); } String javaHome = System.getenv("JAVA_HOME"); if (javaHome != null) { return Paths.get(javaHome).toAbsolutePath(); } return Paths.get("jdk-" + Runtime.version().feature()).toAbsolutePath(); }