修复在 macOS 平台无法找到通过 DMG 安装的 Java 的问题 (#3645)
This commit is contained in:
@@ -376,8 +376,8 @@ public final class JavaManager {
|
|||||||
searchAllJavaInDirectory(javaRuntimes, Paths.get(System.getProperty("user.home"), "/.sdkman/candidates/java")); // SDKMAN!
|
searchAllJavaInDirectory(javaRuntimes, Paths.get(System.getProperty("user.home"), "/.sdkman/candidates/java")); // SDKMAN!
|
||||||
break;
|
break;
|
||||||
case OSX:
|
case OSX:
|
||||||
tryAddJavaHome(javaRuntimes, Paths.get("/Library/Java/JavaVirtualMachines/Contents/Home"));
|
searchJavaInMacJavaVirtualMachines(javaRuntimes, Paths.get("/Library/Java/JavaVirtualMachines"));
|
||||||
tryAddJavaHome(javaRuntimes, Paths.get(System.getProperty("user.home"), "/Library/Java/JavaVirtualMachines/Contents/Home"));
|
searchJavaInMacJavaVirtualMachines(javaRuntimes, Paths.get(System.getProperty("user.home"), "/Library/Java/JavaVirtualMachines"));
|
||||||
tryAddJavaExecutable(javaRuntimes, Paths.get("/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java"));
|
tryAddJavaExecutable(javaRuntimes, Paths.get("/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java"));
|
||||||
tryAddJavaExecutable(javaRuntimes, Paths.get("/Applications/Xcode.app/Contents/Applications/Application Loader.app/Contents/MacOS/itms/java/bin/java"));
|
tryAddJavaExecutable(javaRuntimes, Paths.get("/Applications/Xcode.app/Contents/Applications/Application Loader.app/Contents/MacOS/itms/java/bin/java"));
|
||||||
// Homebrew
|
// Homebrew
|
||||||
@@ -631,6 +631,20 @@ public final class JavaManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void searchJavaInMacJavaVirtualMachines(Map<Path, JavaRuntime> javaRuntimes, Path directory) {
|
||||||
|
if (!Files.isDirectory(directory)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try (DirectoryStream<Path> stream = Files.newDirectoryStream(directory)) {
|
||||||
|
for (Path subDir : stream) {
|
||||||
|
tryAddJavaHome(javaRuntimes, subDir.resolve("Contents/Home"));
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
LOG.warning("Failed to find Java in " + directory, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ==== Windows Registry Support ====
|
// ==== Windows Registry Support ====
|
||||||
private static void queryJavaInRegistryKey(Map<Path, JavaRuntime> javaRuntimes, String location) {
|
private static void queryJavaInRegistryKey(Map<Path, JavaRuntime> javaRuntimes, String location) {
|
||||||
for (String java : querySubFolders(location)) {
|
for (String java : querySubFolders(location)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user