2
0
Fork 0
mirror of https://github.com/ethauvin/bld.git synced 2025-04-25 00:07:12 -07:00

Fix to the bld wrapper to take java.home into account for the java executable, otherwise there can be a mismatch between the javac version and the java version

This commit is contained in:
Geert Bevin 2024-08-23 10:47:40 -04:00
parent a616a8a8f6
commit a7c29080f5

View file

@ -642,7 +642,7 @@ public class Wrapper {
private int launchMainCli(File jarFile, List<String> arguments)
throws IOException, InterruptedException {
var args = new ArrayList<String>();
args.add("java");
args.add(findJavaExecutable());
includeJvmProperties(arguments, args);
args.add("-cp");
@ -695,7 +695,7 @@ public class Wrapper {
}
var java_args = new ArrayList<String>();
java_args.add("java");
java_args.add(findJavaExecutable());
includeJvmProperties(arguments, java_args);
java_args.add("-cp");
@ -712,6 +712,15 @@ public class Wrapper {
return process.waitFor();
}
private static String findJavaExecutable() {
var executable = System.getProperty("os.name").toLowerCase().contains("win") ? "java.exe" : "java";
var java_home = System.getProperty("java.home");
if (null == java_home) {
return executable;
}
return java_home + File.separator + "bin" + File.separator + executable;
}
private static void includeJvmProperties(List<String> arguments, List<String> javaArgs) {
var i = arguments.iterator();
while (i.hasNext()) {