mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-02-05 16:44:47 +08:00
follow environment variables when finding JREs
This commit is contained in:
parent
2e8d1a7702
commit
1b72e43cce
@ -232,20 +232,23 @@ public final class JavaVersion {
|
||||
switch (OperatingSystem.CURRENT_OS) {
|
||||
|
||||
case WINDOWS:
|
||||
Path programFiles = Paths.get(Optional.ofNullable(System.getenv("ProgramFiles")).orElse("C:\\Program Files"));
|
||||
Path programFiles_x86 = Paths.get(Optional.ofNullable(System.getenv("ProgramFiles(x86)")).orElse("C:\\Program Files (x86)"));
|
||||
|
||||
javaExecutables.add(queryJavaHomesInRegistryKey("HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment\\").stream().map(JavaVersion::getExecutable));
|
||||
javaExecutables.add(queryJavaHomesInRegistryKey("HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\").stream().map(JavaVersion::getExecutable));
|
||||
javaExecutables.add(queryJavaHomesInRegistryKey("HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\JRE\\").stream().map(JavaVersion::getExecutable));
|
||||
javaExecutables.add(queryJavaHomesInRegistryKey("HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\JDK\\").stream().map(JavaVersion::getExecutable));
|
||||
javaExecutables.add(listDirectory(Paths.get("C:\\Program Files\\Java")).map(JavaVersion::getExecutable));
|
||||
javaExecutables.add(listDirectory(Paths.get("C:\\Program Files\\BellSoft")).map(JavaVersion::getExecutable));
|
||||
javaExecutables.add(listDirectory(Paths.get("C:\\Program Files\\AdoptOpenJDK")).map(JavaVersion::getExecutable));
|
||||
javaExecutables.add(listDirectory(Paths.get("C:\\Program Files\\Zulu")).map(JavaVersion::getExecutable));
|
||||
javaExecutables.add(listDirectory(Paths.get("C:\\Program Files\\Microsoft")).map(JavaVersion::getExecutable));
|
||||
javaExecutables.add(listDirectory(Paths.get("C:\\Program Files (x86)\\Java")).map(JavaVersion::getExecutable));
|
||||
javaExecutables.add(listDirectory(Paths.get("C:\\Program Files (x86)\\BellSoft")).map(JavaVersion::getExecutable));
|
||||
javaExecutables.add(listDirectory(Paths.get("C:\\Program Files (x86)\\AdoptOpenJDK")).map(JavaVersion::getExecutable));
|
||||
javaExecutables.add(listDirectory(Paths.get("C:\\Program Files (x86)\\Zulu")).map(JavaVersion::getExecutable));
|
||||
javaExecutables.add(listDirectory(Paths.get("C:\\Program Files (x86)\\Microsoft")).map(JavaVersion::getExecutable));
|
||||
javaExecutables.add(listDirectory(programFiles.resolve("Java")).map(JavaVersion::getExecutable));
|
||||
javaExecutables.add(listDirectory(programFiles.resolve("BellSoft")).map(JavaVersion::getExecutable));
|
||||
javaExecutables.add(listDirectory(programFiles.resolve("AdoptOpenJDK")).map(JavaVersion::getExecutable));
|
||||
javaExecutables.add(listDirectory(programFiles.resolve("Zulu")).map(JavaVersion::getExecutable));
|
||||
javaExecutables.add(listDirectory(programFiles.resolve("Microsoft")).map(JavaVersion::getExecutable));
|
||||
javaExecutables.add(listDirectory(programFiles_x86.resolve("Java")).map(JavaVersion::getExecutable));
|
||||
javaExecutables.add(listDirectory(programFiles_x86.resolve("BellSoft")).map(JavaVersion::getExecutable));
|
||||
javaExecutables.add(listDirectory(programFiles_x86.resolve("AdoptOpenJDK")).map(JavaVersion::getExecutable));
|
||||
javaExecutables.add(listDirectory(programFiles_x86.resolve("Zulu")).map(JavaVersion::getExecutable));
|
||||
javaExecutables.add(listDirectory(programFiles_x86.resolve("Microsoft")).map(JavaVersion::getExecutable));
|
||||
if (System.getenv("PATH") != null) {
|
||||
javaExecutables.add(Arrays.stream(System.getenv("PATH").split(";")).map(path -> Paths.get(path, "java.exe")));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user