diff options
-rw-r--r-- | org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaRuntime.java | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaRuntime.java b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaRuntime.java index 6e92ad5d9..c27de612a 100644 --- a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaRuntime.java +++ b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaRuntime.java @@ -1873,7 +1873,7 @@ public final class JavaRuntime { * <li>The default VM</li> * </ul> * This state will be read again upon first access to VM configuration information. - * + * * @throws CoreException * if trying to save the current state of VMs encounters a problem */ @@ -2232,6 +2232,15 @@ public final class JavaRuntime { // Create a stand-in for the detected VM and add it to the result collector String vmID = String.valueOf(unique); VMStandin detectedVMStandin = new VMStandin(vmType, vmID); + + // Java 9 and above needs the vmInstall location till jre + File pluginDir = new File(detectedLocation, "plugins"); //$NON-NLS-1$ + File featuresDir = new File(detectedLocation, "features"); //$NON-NLS-1$ + if (pluginDir.exists() && featuresDir.exists()) { + if (isJREVersionAbove8(vmType, detectedLocation)) { + detectedLocation = new File(detectedLocation, "jre"); //$NON-NLS-1$ + } + } detectedVMStandin.setInstallLocation(detectedLocation); detectedVMStandin.setName(generateDetectedVMName(detectedVMStandin)); if (vmType instanceof AbstractVMInstallType) { @@ -2249,6 +2258,23 @@ public final class JavaRuntime { return null; } + private static boolean isJREVersionAbove8(IVMInstallType vmType, File installLocation) { + LibraryLocation[] locations = vmType.getDefaultLibraryLocations(installLocation); + boolean exist = true; + for (int i = 0; i < locations.length; i++) { + exist = exist && new File(locations[i].getSystemLibraryPath().toOSString()).exists(); + } + if (exist) { + return false; + } + exist = true; + LibraryLocation[] newLocations = vmType.getDefaultLibraryLocations(new File(installLocation, "jre")); //$NON-NLS-1$ + for (int i = 0; i < newLocations.length; i++) { + exist = exist && new File(newLocations[i].getSystemLibraryPath().toOSString()).exists(); + } + return exist; + } + /** * Returns whether the specified option is the same in the given * map and preference store. |