@@ -9,6 +9,7 @@ import org.jackhuang.hmcl.util.platform.JavaVersion;
|
|||||||
import org.jackhuang.hmcl.util.platform.OperatingSystem;
|
import org.jackhuang.hmcl.util.platform.OperatingSystem;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.file.DirectoryStream;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -45,7 +46,8 @@ public final class JavaRepository {
|
|||||||
String platform = platformOptional.get();
|
String platform = platformOptional.get();
|
||||||
Path javaStoragePath = getJavaStoragePath();
|
Path javaStoragePath = getJavaStoragePath();
|
||||||
if (Files.isDirectory(javaStoragePath)) {
|
if (Files.isDirectory(javaStoragePath)) {
|
||||||
for (Path component : Files.newDirectoryStream(javaStoragePath)) {
|
try (DirectoryStream<Path> dirStream = Files.newDirectoryStream(javaStoragePath)) {
|
||||||
|
for (Path component : dirStream) {
|
||||||
Path javaHome = component.resolve(platform).resolve(component.getFileName());
|
Path javaHome = component.resolve(platform).resolve(component.getFileName());
|
||||||
try {
|
try {
|
||||||
addJava(javaHome);
|
addJava(javaHome);
|
||||||
@@ -56,6 +58,7 @@ public final class JavaRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static Optional<String> getCurrentJavaPlatform() {
|
public static Optional<String> getCurrentJavaPlatform() {
|
||||||
if (OperatingSystem.CURRENT_OS == OperatingSystem.LINUX) {
|
if (OperatingSystem.CURRENT_OS == OperatingSystem.LINUX) {
|
||||||
|
|||||||
Reference in New Issue
Block a user