1
0
mirror of https://github.com/SKCraft/Launcher.git synced 2024-11-27 12:46:22 +01:00

GH-443 Fix registry reading under Java 8 (#447)

This commit is contained in:
Henry 2021-11-15 01:32:11 +00:00 committed by GitHub
commit 777d430ace
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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<JavaRuntime> entries, String basePath)
throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
List<String> 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<String> 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);
}
}