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 453e21aa2b8..b850f344ca8 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 boolean accept(File dir, String name) { }); 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 boolean accept(final File pathname) { } 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 boolean accept(File dir, String name) { }); 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 boolean accept(final File pathname) { } 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 boolean accept(final File pathname) { } 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 void testIfClassloaderNotChange() throws Exception { 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; + } }