mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 11:39:11 +03:00
[FIX] JavaHelper NPE
This commit is contained in:
parent
cf802fb0b3
commit
a796b82a16
1 changed files with 5 additions and 2 deletions
|
@ -76,10 +76,13 @@ public synchronized static List<JavaVersion> findJava() {
|
||||||
if (Files.exists(javaExecPath)) {
|
if (Files.exists(javaExecPath)) {
|
||||||
javaExecPath = javaExecPath.toRealPath();
|
javaExecPath = javaExecPath.toRealPath();
|
||||||
p1 = javaExecPath.getParent().getParent();
|
p1 = javaExecPath.getParent().getParent();
|
||||||
|
if(p1 == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
tryAddJava(javaPaths, result, JavaVersion.getByPath(p1));
|
tryAddJava(javaPaths, result, JavaVersion.getByPath(p1));
|
||||||
trySearchJava(javaPaths, result, p1.getParent());
|
trySearchJava(javaPaths, result, p1.getParent());
|
||||||
}
|
}
|
||||||
} catch (InvalidPathException ignored) {
|
} catch (InvalidPathException | NullPointerException ignored) {
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LogHelper.error(e);
|
LogHelper.error(e);
|
||||||
|
@ -128,7 +131,7 @@ public static boolean tryAddJava(List<String> javaPaths, List<JavaVersion> resul
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void trySearchJava(List<String> javaPaths, List<JavaVersion> result, Path path) throws IOException {
|
public static void trySearchJava(List<String> javaPaths, List<JavaVersion> result, Path path) throws IOException {
|
||||||
if (!Files.isDirectory(path)) return;
|
if (path == null || !Files.isDirectory(path)) return;
|
||||||
Files.list(path).filter(p -> Files.exists(p.resolve("bin").resolve(JVMHelper.OS_TYPE == JVMHelper.OS.MUSTDIE ? "java.exe" : "java"))).forEach(e -> {
|
Files.list(path).filter(p -> Files.exists(p.resolve("bin").resolve(JVMHelper.OS_TYPE == JVMHelper.OS.MUSTDIE ? "java.exe" : "java"))).forEach(e -> {
|
||||||
try {
|
try {
|
||||||
tryAddJava(javaPaths, result, JavaVersion.getByPath(e));
|
tryAddJava(javaPaths, result, JavaVersion.getByPath(e));
|
||||||
|
|
Loading…
Reference in a new issue