Bug 546216 - Eclipse does not recognize jre located along with eclipse executable
diff --git a/org.eclipse.jdt.launching/META-INF/MANIFEST.MF b/org.eclipse.jdt.launching/META-INF/MANIFEST.MF index 7c2d3c3..7dd1fdf 100644 --- a/org.eclipse.jdt.launching/META-INF/MANIFEST.MF +++ b/org.eclipse.jdt.launching/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.jdt.launching; singleton:=true -Bundle-Version: 3.13.0.qualifier +Bundle-Version: 3.13.1.qualifier Bundle-Activator: org.eclipse.jdt.internal.launching.LaunchingPlugin Bundle-Vendor: %providerName Bundle-Localization: plugin
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 9d4a144..d3a3325 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
@@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2018 IBM Corporation and others. + * Copyright (c) 2000, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -2233,6 +2233,15 @@ // 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) { @@ -2250,6 +2259,23 @@ 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.
diff --git a/org.eclipse.jdt.launching/pom.xml b/org.eclipse.jdt.launching/pom.xml index fd48417..cfb1d85 100644 --- a/org.eclipse.jdt.launching/pom.xml +++ b/org.eclipse.jdt.launching/pom.xml
@@ -18,7 +18,7 @@ </parent> <groupId>org.eclipse.jdt</groupId> <artifactId>org.eclipse.jdt.launching</artifactId> - <version>3.13.0-SNAPSHOT</version> + <version>3.13.1-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> <build>