Here you can find the source of getJDKHomeVariable()
public static String getJDKHomeVariable()
//package com.java2s; // %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt import java.io.File; public class Main { public static String getJDKHomeVariable() { String jdkHome = System.getProperty("jdk.home"); //$NON-NLS-1$ if (jdkHome == null || "".equals(jdkHome)) { //$NON-NLS-1$ jdkHome = getJDKHomeFromEclipseVm(); }// www . jav a2 s.c o m if (jdkHome == null || "".equals(jdkHome)) { //$NON-NLS-1$ jdkHome = System.getenv("JDK_HOME"); //$NON-NLS-1$ } return jdkHome; } private static String getJDKHomeFromEclipseVm() { String eclipseVm = System.getProperty("eclipse.vm"); //$NON-NLS-1$ if (eclipseVm != null && !"".equals(eclipseVm)) { File javaexe = new File(eclipseVm); if (javaexe.exists()) { String jdk = getJDKPath(javaexe); if (jdk != null && new File(jdk, "lib/tools.jar").exists()) {//$NON-NLS-1$ return jdk; } } } return null; } private static String getJDKPath(File file) { if (file == null) { return null; } if ("bin".equals(file.getName())) {//$NON-NLS-1$ return file.getParent(); } else { return getJDKPath(file.getParentFile()); } } }