Example usage for java.lang Runtime version

List of usage examples for java.lang Runtime version

Introduction

In this page you can find the example usage for java.lang Runtime version.

Prototype

Version version

To view the source code for java.lang Runtime version.

Click Source Link

Usage

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();
    }/* w  w  w  . ja v a  2s  . c  o 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();
}