Skip to content

Commit

Permalink
Fix to the bld wrapper to take java.home into account for the java ex…
Browse files Browse the repository at this point in the history
…ecutable, otherwise there can be a mismatch between the javac version and the java version
  • Loading branch information
gbevin committed Aug 23, 2024
1 parent a616a8a commit a7c2908
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/main/java/rife/bld/wrapper/Wrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ private int launchMain(File jarFile, List<String> arguments)
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");
Expand Down Expand Up @@ -695,7 +695,7 @@ private int launchMainBuild(File jarFile, List<String> arguments)
}

var java_args = new ArrayList<String>();
java_args.add("java");
java_args.add(findJavaExecutable());
includeJvmProperties(arguments, java_args);

java_args.add("-cp");
Expand All @@ -712,6 +712,15 @@ private int launchMainBuild(File jarFile, List<String> arguments)
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()) {
Expand Down

0 comments on commit a7c2908

Please sign in to comment.