Java Utililty Methods JDK Home Get

List of utility methods to do JDK Home Get

Description

The list of methods to do JDK Home Get are organized into topic(s).

Method

StringgetJdkBin()
get Jdk Bin
File bin = new File(getJdkHome() + File.separator + "bin");
if (!bin.exists()) {
    throw new IOException("Unable to locate JDK bin: '" + bin + "'");
return bin.getAbsolutePath();
StringgetJdkHome()
get Jdk Home
String javaHome = System.getProperty("java.home");
if (!javaHome.endsWith(File.separator + "jre")) {
    throw new IOException("Unable to locate executable JDK Home.");
return javaHome.substring(0, javaHome.length() - 4);
FilegetJdkHome()
Return a lazy guess at the JDK home based on the JAVA_HOME.
List<String> candidates = new ArrayList<String>();
candidates.add(System.getProperty(GRADLE_VIEW_JAVA_HOME_KEY));
candidates.add(System.getenv("JAVA_HOME"));
for (String candidate : candidates) {
    if (candidate != null) {
        File jdkHome = new File(candidate);
        if (jdkHome.exists()) {
            return jdkHome;
...
StringgetJDKHomeVariable()
get JDK Home Variable
String jdkHome = System.getProperty("jdk.home"); 
if (jdkHome == null || "".equals(jdkHome)) { 
    jdkHome = getJDKHomeFromEclipseVm();
if (jdkHome == null || "".equals(jdkHome)) { 
    jdkHome = System.getenv("JDK_HOME"); 
return jdkHome;
...
StringgetJDKPath(File file)
get JDK Path
if (file == null) {
    return null;
if ("bin".equals(file.getName())) {
    return file.getParent();
} else {
    return getJDKPath(file.getParentFile());