You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by ju...@apache.org on 2024/11/27 06:53:46 UTC
(tomee) branch main updated: TomEECliIT locate java binary using java.home
This is an automated email from the ASF dual-hosted git repository.
jungm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomee.git
The following commit(s) were added to refs/heads/main by this push:
new 42608f8808 TomEECliIT locate java binary using java.home
42608f8808 is described below
commit 42608f880822f5b9cf199ccef67fd521feb720cd
Author: Markus Jung <ju...@apache.org>
AuthorDate: Wed Nov 27 07:53:00 2024 +0100
TomEECliIT locate java binary using java.home
this allows cases where $JAVA_HOME points to another JDK than the one in the $PATH
---
.../src/test/java/org/apache/tomee/TomEECliIT.java | 27 ++++++++++++++--------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/tomee/apache-tomee/src/test/java/org/apache/tomee/TomEECliIT.java b/tomee/apache-tomee/src/test/java/org/apache/tomee/TomEECliIT.java
index 453e21aa2b..b850f344ca 100644
--- a/tomee/apache-tomee/src/test/java/org/apache/tomee/TomEECliIT.java
+++ b/tomee/apache-tomee/src/test/java/org/apache/tomee/TomEECliIT.java
@@ -89,11 +89,11 @@ public class TomEECliIT {
});
final ProcessBuilder builder = new ProcessBuilder()
- .command("java", "-cp", jar.getAbsolutePath() + File.pathSeparator +
- tomee.getAbsolutePath() + File.separator + "lib" + File.separator + openejbCore[0] + File.pathSeparator +
- tomee.getAbsolutePath() + File.separator + "lib" + File.separator + commonsCli[0] + File.pathSeparator +
- tomee.getAbsolutePath() + File.separator + "lib" + File.separator + commonsLang[0],
- "org.apache.openejb.cli.Bootstrap", "classloadertest");
+ .command(getJavaBinaryPath(), "-cp", jar.getAbsolutePath() + File.pathSeparator +
+ tomee.getAbsolutePath() + File.separator + "lib" + File.separator + openejbCore[0] + File.pathSeparator +
+ tomee.getAbsolutePath() + File.separator + "lib" + File.separator + commonsCli[0] + File.pathSeparator +
+ tomee.getAbsolutePath() + File.separator + "lib" + File.separator + commonsLang[0],
+ "org.apache.openejb.cli.Bootstrap", "classloadertest");
final Process start = builder.start();
start.waitFor();
@@ -133,7 +133,7 @@ public class TomEECliIT {
}
final ProcessBuilder builder = new ProcessBuilder()
- .command("java", "-cp", file.getAbsolutePath() + File.separator + "*" + File.pathSeparator +
+ .command(getJavaBinaryPath(), "-cp", file.getAbsolutePath() + File.separator + "*" + File.pathSeparator +
tomee.getAbsolutePath() + File.separator + "lib" + File.separator + "*",
"org.apache.openejb.cli.Bootstrap", "classloadertest");
@@ -205,7 +205,7 @@ public class TomEECliIT {
});
final ProcessBuilder builder = new ProcessBuilder()
- .command("java", "-cp", jar.getAbsolutePath() + File.pathSeparator +
+ .command(getJavaBinaryPath(), "-cp", jar.getAbsolutePath() + File.pathSeparator +
jar2.getAbsolutePath() + File.pathSeparator +
tomee.getAbsolutePath() + File.separator + "lib" + File.separator + openejbCore[0] + File.pathSeparator +
tomee.getAbsolutePath() + File.separator + "lib" + File.separator + commonsCli[0] + File.pathSeparator +
@@ -258,7 +258,7 @@ public class TomEECliIT {
}
final ProcessBuilder builder = new ProcessBuilder()
- .command("java", "-cp", file.getAbsolutePath() + File.separator + "*" + File.pathSeparator +
+ .command(getJavaBinaryPath(), "-cp", file.getAbsolutePath() + File.separator + "*" + File.pathSeparator +
tomee.getAbsolutePath() + File.separator + "lib" + File.separator + "*",
"org.apache.openejb.cli.Bootstrap", "classloadertest2");
@@ -308,7 +308,7 @@ public class TomEECliIT {
}
final ProcessBuilder builder = new ProcessBuilder()
- .command("java", "-cp", file.getAbsolutePath() + File.separator + "*" + File.pathSeparator +
+ .command(getJavaBinaryPath(), "-cp", file.getAbsolutePath() + File.separator + "*" + File.pathSeparator +
tomee.getAbsolutePath() + File.separator + "lib" + File.separator + "*",
"org.apache.openejb.cli.Bootstrap", "classloadertest2");
@@ -325,4 +325,13 @@ public class TomEECliIT {
new Bootstrap().main(new String[]{"cipher"});
assertEquals(originalClassLoader, Thread.currentThread().getContextClassLoader());
}
+
+ protected String getJavaBinaryPath() {
+ String javaExecutable = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java";
+ if (System.getProperty("os.name").startsWith("Win")) {
+ javaExecutable += ".exe";
+ }
+
+ return javaExecutable;
+ }
}