mirror of
https://github.com/SKCraft/Launcher.git
synced 2024-11-27 12:46:22 +01:00
Possibly improve detection of 32-bit/64-bit.
This commit is contained in:
parent
300c8167d8
commit
c1cbff754e
@ -11,6 +11,7 @@ import com.skcraft.launcher.util.Platform;
|
|||||||
import com.skcraft.launcher.util.WinRegistry;
|
import com.skcraft.launcher.util.WinRegistry;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -49,7 +50,8 @@ public final class JavaRuntimeFinder {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void getEntriesFromRegistry(List<JREEntry> entries, String basePath) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
|
private static void getEntriesFromRegistry(List<JREEntry> entries, String basePath)
|
||||||
|
throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
|
||||||
List<String> subKeys = WinRegistry.readStringSubKeys(WinRegistry.HKEY_LOCAL_MACHINE, basePath);
|
List<String> subKeys = WinRegistry.readStringSubKeys(WinRegistry.HKEY_LOCAL_MACHINE, basePath);
|
||||||
for (String subKey : subKeys) {
|
for (String subKey : subKeys) {
|
||||||
JREEntry entry = getEntryFromRegistry(basePath, subKey);
|
JREEntry entry = getEntryFromRegistry(basePath, subKey);
|
||||||
@ -59,7 +61,7 @@ public final class JavaRuntimeFinder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static JREEntry getEntryFromRegistry(String basePath, String version) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
|
private static JREEntry getEntryFromRegistry(String basePath, String version) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
|
||||||
String regPath = basePath + "\\" + version;
|
String regPath = basePath + "\\" + version;
|
||||||
String path = WinRegistry.readString(WinRegistry.HKEY_LOCAL_MACHINE, regPath, "JavaHome");
|
String path = WinRegistry.readString(WinRegistry.HKEY_LOCAL_MACHINE, regPath, "JavaHome");
|
||||||
File dir = new File(path);
|
File dir = new File(path);
|
||||||
@ -75,8 +77,12 @@ public final class JavaRuntimeFinder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean guessIf64Bit(File path) {
|
private static boolean guessIf64Bit(File path) {
|
||||||
String programFilesX86 = System.getenv("ProgramFiles(x86)");
|
try {
|
||||||
return programFilesX86 == null || !path.toString().startsWith(new File(programFilesX86).toString());
|
String programFilesX86 = System.getenv("ProgramFiles(x86)");
|
||||||
|
return programFilesX86 == null || !path.getCanonicalPath().startsWith(new File(programFilesX86).getCanonicalPath());
|
||||||
|
} catch (IOException ignored) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class JREEntry implements Comparable<JREEntry> {
|
private static class JREEntry implements Comparable<JREEntry> {
|
||||||
|
Loading…
Reference in New Issue
Block a user