From b3cbba27090415347d4d132f1bb911fd81795ad9 Mon Sep 17 00:00:00 2001 From: Magi1053 Date: Sun, 14 Nov 2021 19:19:16 -0600 Subject: [PATCH] Fix not checking all registry keys for jvm if the previous key did not exist in the registry. --- .../launcher/launch/JavaRuntimeFinder.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/launcher/src/main/java/com/skcraft/launcher/launch/JavaRuntimeFinder.java b/launcher/src/main/java/com/skcraft/launcher/launch/JavaRuntimeFinder.java index 57f116d..85d953e 100644 --- a/launcher/src/main/java/com/skcraft/launcher/launch/JavaRuntimeFinder.java +++ b/launcher/src/main/java/com/skcraft/launcher/launch/JavaRuntimeFinder.java @@ -50,13 +50,9 @@ public final class JavaRuntimeFinder { launcherDir = new File(programFiles, "Minecraft Launcher"); } - try { - getEntriesFromRegistry(entries, "SOFTWARE\\JavaSoft\\Java Runtime Environment"); - getEntriesFromRegistry(entries, "SOFTWARE\\JavaSoft\\Java Development Kit"); - getEntriesFromRegistry(entries, "SOFTWARE\\JavaSoft\\JDK"); - } catch (Throwable err) { - log.log(Level.WARNING, "Failed to read Java locations from registry", err); - } + getEntriesFromRegistry(entries, "SOFTWARE\\JavaSoft\\Java Runtime Environment"); + getEntriesFromRegistry(entries, "SOFTWARE\\JavaSoft\\Java Development Kit"); + getEntriesFromRegistry(entries, "SOFTWARE\\JavaSoft\\JDK"); } else if (env.getPlatform() == Platform.LINUX) { launcherDir = new File(System.getenv("HOME"), ".minecraft"); @@ -159,13 +155,17 @@ public final class JavaRuntimeFinder { } private static void getEntriesFromRegistry(Collection entries, String basePath) - throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { - List subKeys = WinRegistry.readStringSubKeys(WinRegistry.HKEY_LOCAL_MACHINE, basePath); - for (String subKey : subKeys) { - JavaRuntime entry = getEntryFromRegistry(basePath, subKey); - if (entry != null) { - entries.add(entry); + throws IllegalArgumentException { + try { + List subKeys = WinRegistry.readStringSubKeys(WinRegistry.HKEY_LOCAL_MACHINE, basePath); + for (String subKey : subKeys) { + JavaRuntime entry = getEntryFromRegistry(basePath, subKey); + if (entry != null) { + entries.add(entry); + } } + } catch (Throwable err) { + log.log(Level.INFO, "Failed to read Java locations from registry in " + basePath); } }