diff options
author | nea <nea@nea.moe> | 2023-11-01 23:04:25 +0100 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-11-01 23:04:25 +0100 |
commit | 2d1bf11103b2635181ecb64c9be0638714328fe0 (patch) | |
tree | d548c12188a40a48961c18636ab0ef54e6fcac26 /src/main/java/moe/nea/modernjava/launch/relaunch/FCPRelauncher.java | |
parent | 21ca764e26fdbb903ce380874cc2798f17de9034 (diff) | |
download | ModernJavaLauncher-2d1bf11103b2635181ecb64c9be0638714328fe0.tar.gz ModernJavaLauncher-2d1bf11103b2635181ecb64c9be0638714328fe0.tar.bz2 ModernJavaLauncher-2d1bf11103b2635181ecb64c9be0638714328fe0.zip |
Add java binary finder
Diffstat (limited to 'src/main/java/moe/nea/modernjava/launch/relaunch/FCPRelauncher.java')
-rw-r--r-- | src/main/java/moe/nea/modernjava/launch/relaunch/FCPRelauncher.java | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/main/java/moe/nea/modernjava/launch/relaunch/FCPRelauncher.java b/src/main/java/moe/nea/modernjava/launch/relaunch/FCPRelauncher.java index fe74c42..3e13806 100644 --- a/src/main/java/moe/nea/modernjava/launch/relaunch/FCPRelauncher.java +++ b/src/main/java/moe/nea/modernjava/launch/relaunch/FCPRelauncher.java @@ -46,7 +46,19 @@ public class FCPRelauncher { } public static File findJavaLauncher() { - return new File("/home/nea/.sdkman/candidates/java/16.0.2-tem/bin/java"); + JavaScanner javaScanner = new JavaScanner(); + javaScanner.scanDefaultPaths(); + javaScanner.prettyPrint(); + JavaScanner.LocalJavaVersion candidate = javaScanner.findCandidate(); + if (candidate == null) { + System.err.println("Looks like we couldn't find a java candidate. Either install one, or if you have one" + + " and we just cannot find it, specify -D" + PropertyNames.JAVA_SCAN_PATH + "=<java home here>." + + " We need a Java 16 JDK. Exiting now."); + IAMFML.shutdown(1); + throw new RuntimeException(); + } + System.out.println("Choosing Java Candidate:\n" + candidate.prettyPrint()); + return candidate.getJavaBinary(); } public static File findAgentJar() { |