Bug 526783: Add ability to run tests on custom JDK

Signed-off-by: Lukas Jungmann <lukas.jungmann@oracle.com>
diff --git a/dbws/eclipselink.dbws.test.oracle/antbuild.xml b/dbws/eclipselink.dbws.test.oracle/antbuild.xml
index b8ffd32..bd80c8f 100644
--- a/dbws/eclipselink.dbws.test.oracle/antbuild.xml
+++ b/dbws/eclipselink.dbws.test.oracle/antbuild.xml
@@ -75,6 +75,10 @@
 
     <property name="jacocoagent.lib" value="${extensions.depend.dir}/${jacocoagent.jar}"/>
 
+    <!-- JVM used to run tests -->
+    <property name="test.junit.jvm" value="${env.JAVA_HOME}"/>
+    <property name="test.junit.jvm.exec" value="${test.junit.jvm}/bin/java"/>
+
   <!-- OS environment variables have 'env' as a prefix -->
   <property environment="env"/>
   <presetdef
@@ -254,6 +258,7 @@
       <!-- Can be set e.g. in test.properties to add VM options for a particular platform/driver  -->
       <property name="additional.jvmargs" value="-Ddummy2=dummy"/>
       <junit
+        jvm="${test.junit.jvm.exec}"
         printsummary="withOutAndErr"
         fork="yes"
         forkmode="once"
diff --git a/dbws/eclipselink.dbws.test/antbuild.xml b/dbws/eclipselink.dbws.test/antbuild.xml
index 26851c8..adc86b0 100644
--- a/dbws/eclipselink.dbws.test/antbuild.xml
+++ b/dbws/eclipselink.dbws.test/antbuild.xml
@@ -93,6 +93,10 @@
     <property name="version.string" value="${release.version}.qualifier"/>
     <property name="release.designation"  value="EclipseLink DeveloperBuild"/>
 
+    <!-- JVM used to run tests -->
+    <property name="test.junit.jvm" value="${env.JAVA_HOME}"/>
+    <property name="test.junit.jvm.exec" value="${test.junit.jvm}/bin/java"/>
+
     <!-- Set Compile Path-->
     <path id="dbws_test.compile.path">
         <pathelement path="${junit.lib}"/>
@@ -214,6 +218,7 @@
       <!-- Can be set e.g. in test.properties to add VM options for a particular platform/driver  -->
       <property name="additional.jvmargs" value="-Ddummy2=dummy"/>
       <junit
+        jvm="${test.junit.jvm.exec}"
         printsummary="withOutAndErr"
         fork="yes"
         forkmode="once"
diff --git a/foundation/eclipselink.core.test/antbuild.xml b/foundation/eclipselink.core.test/antbuild.xml
index cfb8de6..0b0df93 100644
--- a/foundation/eclipselink.core.test/antbuild.xml
+++ b/foundation/eclipselink.core.test/antbuild.xml
@@ -92,6 +92,10 @@
     <property file="${core_test.build.location}/${test.properties}"/>
     <property file="${core_test.build.location}/test.properties"/>
 
+    <!-- JVM used to run tests -->
+    <property name="test.junit.jvm" value="${env.JAVA_HOME}"/>
+    <property name="test.junit.jvm.exec" value="${test.junit.jvm}/bin/java"/>
+
     <!-- Local path variables -->
     <property name="core_test.src.dir"      value="${core_test.build.location}/${src.dir}"/>
     <property name="core_test.resource.dir" value="${core_test.build.location}/${resource.dir}"/>
@@ -547,7 +551,7 @@
         <property name="additional.jvmargs" value="-Ddummy2=dummy"/>
         <!-- 282012: On a 64-bit JVM - The XML processing at the end of the testing requires at least 1536 -->
         <!-- Note: on a legacy XP OS with 4GB ram - the max is 1536 - use of 2048 will cause [junit] [WARN ] Unable to acquire some virtual address space - reduced from 2048 to 1908MB. -->
-        <junit printsummary="yes" failureproperty="junit.failed" fork="yes" forkmode="once" showoutput="true" maxmemory="${max.heap.memory}" dir="${core_test.run.dir}">
+        <junit jvm="${test.junit.jvm.exec}" printsummary="yes" failureproperty="junit.failed" fork="yes" forkmode="once" showoutput="true" maxmemory="${max.heap.memory}" dir="${core_test.run.dir}">
             <jvmarg value="-Declipselink.logging.level=${logging.level}"/>
             <jvmarg value="-Ddb.driver=${db.driver}"/>
             <jvmarg value="-Ddb.url=${db.url}"/>
diff --git a/foundation/eclipselink.extension.test/antbuild.xml b/foundation/eclipselink.extension.test/antbuild.xml
index 2fbe46e..70b0fb3 100644
--- a/foundation/eclipselink.extension.test/antbuild.xml
+++ b/foundation/eclipselink.extension.test/antbuild.xml
@@ -150,7 +150,7 @@
             <echo message=" - loglevel:  @{loglevel}"/>
             <!-- Can be set e.g. in test.properties to add VM options for a particular platform/driver  -->
             <property name="additional.jvmargs" value="-Ddummy2=dummy"/>
-            <junit printsummary="yes" failureproperty="junit.failed" fork="yes" forkmode="once"
+            <junit jvm="${test.junit.jvm.exec}" printsummary="yes" failureproperty="junit.failed" fork="yes" forkmode="once"
                    showoutput="true" maxmemory="512m" dir="@{dir}">
                 <jvmarg value="-Declipselink.logging.level=@{loglevel}"/>
                 <!--jvmarg value="-Djava.security.manager"/>
@@ -198,6 +198,10 @@
     <!-- Core tests directory -->
     <property name="core.test.dir" location="../eclipselink.core.test"/>
 
+    <!-- JVM used to run tests -->
+    <property name="test.junit.jvm" value="${env.JAVA_HOME}"/>
+    <property name="test.junit.jvm.exec" value="${test.junit.jvm}/bin/java"/>
+
     <!-- Initialize common path. -->
     <target name="common-path">
         <path id="core.extension.common.path">
diff --git a/jpa/eclipselink.jpa.test.jse/antbuild.xml b/jpa/eclipselink.jpa.test.jse/antbuild.xml
index 0654f08..a7829e5 100644
--- a/jpa/eclipselink.jpa.test.jse/antbuild.xml
+++ b/jpa/eclipselink.jpa.test.jse/antbuild.xml
@@ -32,6 +32,10 @@
     <property file="./antbuild.properties" />
     <property file="./test.properties" />
 
+    <!-- JVM used to run tests -->
+    <property name="test.junit.jvm" value="${env.JAVA_HOME}"/>
+    <property name="test.junit.jvm.exec" value="${test.junit.jvm}/bin/java"/>
+
     <path id="compile.jse.path">
         <pathelement path="${jse.el.root}/eclipselink.jar" />
         <pathelement path="${javax.transaction}" />
@@ -73,7 +77,7 @@
         <property name="additional.jvmargs" value="-Ddummy2=dummy"/>
         <property name="debugargs" value="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=7777"/>
         <property name="rmi" value="-Djava.naming.provider.url=rmi://localhost:${rmi.port} -Djava.naming.factory.initial=com.sun.jndi.rmi.registry.RegistryContextFactory"/>
-        <junit printsummary="on" haltonfailure="false" failureproperty="fail" fork="yes" dir="${jse.classes.dir}" forkmode="once">
+        <junit jvm="${test.junit.jvm.exec}" printsummary="on" haltonfailure="false" failureproperty="fail" fork="yes" dir="${jse.classes.dir}" forkmode="once">
             <jvmarg line="${additional.jvmargs} ${rmi}"/>
             <sysproperty key="javax.persistence.jdbc.url" value="${db.url}"/>
             <sysproperty key="javax.persistence.jdbc.driver" value="${db.driver}"/>
diff --git a/jpa/eclipselink.jpa.test/antbuild.xml b/jpa/eclipselink.jpa.test/antbuild.xml
index 5979113..50af321 100644
--- a/jpa/eclipselink.jpa.test/antbuild.xml
+++ b/jpa/eclipselink.jpa.test/antbuild.xml
@@ -138,6 +138,10 @@
     <property name="modelgen.jar" value="${eclipselink.modelgen.prefix}_${version.string}.jar"/>
     <property name="projectcache.dir"       value="pcfile"/>
 
+    <!-- JVM used to run tests -->
+    <property name="test.junit.jvm" value="${env.JAVA_HOME}"/>
+    <property name="test.junit.jvm.exec" value="${test.junit.jvm}/bin/java"/>
+
     <echo message="modelgen.jar                         = '${modelgen.jar}'"/>
     <echo message="ant.project.name                     = '${ant.project.name}'"/>
     <echo message="jpatest.build.location               = '${jpatest.build.location}'"/>
@@ -2514,7 +2518,7 @@
         <!--<property name="additional.jvmargs" value="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8787"/>-->
         <property name="additional.jvmargs" value="-Ddummy2=dummy"/>
 
-        <junit printsummary="yes" haltonfailure="${test.haltonfailure}" fork="yes" forkmode="once" showoutput="true" maxmemory="${max.heap.memory}" dir="${run.dir}">
+        <junit jvm="${test.junit.jvm.exec}" printsummary="yes" haltonfailure="${test.haltonfailure}" fork="yes" forkmode="once" showoutput="true" maxmemory="${max.heap.memory}" dir="${run.dir}">
             <sysproperty key="proxy.user.name" value="PAS_PROXY"/>
             <sysproperty key="pa.connection.user" value="${db.user}"/>
             <sysproperty key="pa.connection.password" value="${db.pwd}"/>
diff --git a/jpa/eclipselink.jpa.wdf.test/antbuild.xml b/jpa/eclipselink.jpa.wdf.test/antbuild.xml
index 2f17664..0f27f6b 100644
--- a/jpa/eclipselink.jpa.wdf.test/antbuild.xml
+++ b/jpa/eclipselink.jpa.wdf.test/antbuild.xml
@@ -78,6 +78,10 @@
 
     <property name="jacocoagent.lib"       value="${extensions.depend.dir}/${jacocoagent.jar}"/>
 
+    <!-- JVM used to run tests -->
+    <property name="test.junit.jvm" value="${env.JAVA_HOME}"/>
+    <property name="test.junit.jvm.exec" value="${test.junit.jvm}/bin/java"/>
+
     <!-- Default ant targets, compiles and packages test jars, does not run tests. -->
     <target name="build-against-jar"     depends="clean, init_against_jar, compile, package"                description="build JPA WDF testing jars"/>
     <target name="build-against-classes" depends="clean, init_against_classes, compile, package"            description="build JPA WDF testing jars"/>
@@ -320,7 +324,7 @@
         </condition>
         <!-- Can be set e.g. in test.properties to add VM options for a particular platform/driver  -->
         <property name="additional.jvmargs" value="-Ddummy2=dummy"/>
-        <junit printsummary="yes" haltonfailure="yes" fork="yes" forkmode="once" showoutput="true" maxmemory="512m" dir="${run.dir}">
+        <junit jvm="${test.junit.jvm.exec}" printsummary="yes" haltonfailure="yes" fork="yes" forkmode="once" showoutput="true" maxmemory="512m" dir="${run.dir}">
             <jvmarg value="${TEST_AGENT}"/>
             <jvmarg value="${TEST_WEAVING}"/>
             <jvmarg value="${ORM_TESTING}"/>
diff --git a/jpa/eclipselink.jpars.test/antbuild.xml b/jpa/eclipselink.jpars.test/antbuild.xml
index eb35398..99682ac 100644
--- a/jpa/eclipselink.jpars.test/antbuild.xml
+++ b/jpa/eclipselink.jpars.test/antbuild.xml
@@ -107,6 +107,10 @@
 
     <property file="${jparstest.build.location}/antbuild.properties"/>
 
+    <!-- JVM used to run tests -->
+    <property name="test.junit.jvm" value="${env.JAVA_HOME}"/>
+    <property name="test.junit.jvm.exec" value="${test.junit.jvm}/bin/java"/>
+
     <!-- Clean all build generated content. -->
     <target name="clean" description="Clean the build">
         <delete includeEmptyDirs="true" failonerror="false">
@@ -455,7 +459,7 @@
             <echo message="Running @{testclass} suite"/>
             <!-- Can be set e.g. in test.properties to add VM options for a particular platform/driver  -->
             <property name="additional.jvmargs" value="-Ddummy2=dummy"/>
-            <junit printsummary="withOutAndErr" fork="yes" dir="${classes.dir}" maxmemory="512m" showoutput="yes">
+            <junit jvm="${test.junit.jvm.exec}" printsummary="withOutAndErr" fork="yes" dir="${classes.dir}" maxmemory="512m" showoutput="yes">
                 <jvmarg value="-Ddb.driver=${db.driver}"/>
                 <jvmarg value="-Ddb.url=${db.url}"/>
                 <jvmarg value="-Ddb.user=${db.user}"/>
diff --git a/jpa/org.eclipse.persistence.jpa.jpql.test/antbuild.xml b/jpa/org.eclipse.persistence.jpa.jpql.test/antbuild.xml
index e8c15cd..1bb697f 100644
--- a/jpa/org.eclipse.persistence.jpa.jpql.test/antbuild.xml
+++ b/jpa/org.eclipse.persistence.jpa.jpql.test/antbuild.xml
@@ -92,6 +92,10 @@
     <property name="version.qualifier"     value="qualifier"/>
     <property name="version.string"        value="${release.version}.${version.qualifier}"/>
 
+    <!-- JVM used to run tests -->
+    <property name="test.junit.jvm" value="${env.JAVA_HOME}"/>
+    <property name="test.junit.jvm.exec" value="${test.junit.jvm}/bin/java"/>
+
     <echo message="ant.project.name                 = '${ant.project.name}'"/>
     <echo message="hermes.test.build.location       = '${hermes.test.build.location}'"/>
     <echo message="hermes.test.2.base.dir           = '${hermes.test.2.base.dir}'"/>
@@ -196,7 +200,7 @@
         <!-- Can be set e.g. in test.properties to add VM options for a particular platform/driver  -->
         <property name="additional.jvmargs" value="-Ddummy2=dummy"/>
 
-        <junit printsummary="yes" haltonfailure="yes" fork="yes" forkmode="once" showoutput="true" maxmemory="${max.heap.memory}" dir="${run.dir}">
+        <junit jvm="${test.junit.jvm.exec}" printsummary="yes" haltonfailure="yes" fork="yes" forkmode="once" showoutput="true" maxmemory="${max.heap.memory}" dir="${run.dir}">
             <jvmarg value="-Declipselink.logging.level=${logging.level}"/>
             <jvmarg line="${additional.jvmargs}"/>
             <classpath>
diff --git a/moxy/eclipselink.moxy.test/antbuild.xml b/moxy/eclipselink.moxy.test/antbuild.xml
index 2386173..12c0c76 100644
--- a/moxy/eclipselink.moxy.test/antbuild.xml
+++ b/moxy/eclipselink.moxy.test/antbuild.xml
@@ -106,6 +106,10 @@
         </and>
     </condition>
 
+    <!-- JVM used to run tests -->
+    <property name="test.junit.jvm" value="${env.JAVA_HOME}"/>
+    <property name="test.junit.jvm.exec" value="${test.junit.jvm}/bin/java"/>
+
     <path id="xml.parser.path">
         <fileset
                 dir="${xml.parser.jar.dir}"
@@ -353,12 +357,12 @@
         <echo message="    -Dclassworlds.conf=${M2_HOME}/bin/m2.conf"/>
         <echo message="    -Dmaven.home=${M2_HOME}"/>
         <echo message="    -Dbuild.qualifier=${version.qualifier}"/>
-        <java dir="${basedir}" fork="true" failonerror="true" classname="org.codehaus.plexus.classworlds.launcher.Launcher">
+        <java jvm="${test.junit.jvm.exec}" dir="${basedir}" fork="true" failonerror="true" classname="org.codehaus.plexus.classworlds.launcher.Launcher">
             <jvmarg value="-Dclassworlds.conf=${M2_HOME}/bin/m2.conf"/>
             <jvmarg value="-Dmaven.home=${M2_HOME}"/>
             <jvmarg value="-Dmaven.multiModuleProjectDirectory=${basedir}"/>
             <!--<arg line="-Dmaven.surefire.debug clean install"/>-->
-            <arg line="clean install"/>
+            <arg line="clean test"/>
             <arg line="-Dmoxytest.2.common.plugins.dir=${basedir}/../../plugins/"/>
             <arg line="-Djavax.validation.lib=${basedir}/${javax.validation.lib}"/>
             <arg line="-Dbuild.qualifier=${version.qualifier}"/>
@@ -384,7 +388,7 @@
         <delete dir="${report.dir}/installer" failonerror="false"/>
         <mkdir dir="${report.dir}/installer"/>
         <mkdir dir="${build.dir}/${test.dir}"/>
-        <junit printsummary="yes" fork="true" dir="${build.dir}/${test.dir}" tempdir="${build.dir}/${test.dir}" showoutput="yes" maxmemory="512m">
+        <junit jvm="${test.junit.jvm.exec}" printsummary="yes" fork="true" dir="${build.dir}/${test.dir}" tempdir="${build.dir}/${test.dir}" showoutput="yes" maxmemory="512m">
             <env key="ECLIPSELINK_UNZIP_DIR" value="${unzip.temp.file}"/>
             <batchtest todir="${report.dir}/installer">
                 <fileset dir="${src.dir}">
@@ -497,7 +501,7 @@
             <mkdir dir="${build.dir}/${test.dir}/${tmp.dir}"/>
             <!-- Can be set e.g. in test.properties to add VM options for a particular platform/driver  -->
             <property name="additional.jvmargs" value="-Ddummy2=dummy"/>
-            <junit printsummary="yes" fork="true" dir="${build.dir}/${test.dir}" tempdir="${build.dir}/${test.dir}" showoutput="yes" maxmemory="512m">
+            <junit jvm="${test.junit.jvm.exec}" printsummary="yes" fork="true" dir="${build.dir}/${test.dir}" tempdir="${build.dir}/${test.dir}" showoutput="yes" maxmemory="512m">
                 <!--<jvmarg value="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"/>-->
                 <jvmarg value="-ea"/>
                 <jvmarg value="-javaagent:${jmockit.lib}"/>
@@ -562,7 +566,7 @@
             <mkdir dir="${build.dir}/${test.dir}/${tmp.dir}"/>
             <!-- Can be set e.g. in test.properties to add VM options for a particular platform/driver  -->
             <property name="additional.jvmargs" value="-Ddummy2=dummy"/>
-            <junit printsummary="yes" fork="true" dir="${build.dir}/${test.dir}" tempdir="${build.dir}/${test.dir}" showoutput="yes" maxmemory="512m">
+            <junit jvm="${test.junit.jvm.exec}" printsummary="yes" fork="true" dir="${build.dir}/${test.dir}" tempdir="${build.dir}/${test.dir}" showoutput="yes" maxmemory="512m">
                 <jvmarg value="-ea"/>
                 <jvmarg line="${additional.jvmargs}"/>
                 <env key="T_WORK" value="${tmp.dir}"/>
@@ -590,7 +594,7 @@
             <delete dir="${report.dir}/srg/oxm" failonerror="false"/>
             <mkdir dir="${report.dir}/srg/oxm/default"/>
             <mkdir dir="${build.dir}/${test.dir}"/>
-            <junit printsummary="yes" fork="true" dir="${build.dir}/${test.dir}" tempdir="${build.dir}/${test.dir}" showoutput="yes" maxmemory="512m">
+            <junit jvm="${test.junit.jvm.exec}" printsummary="yes" fork="true" dir="${build.dir}/${test.dir}" tempdir="${build.dir}/${test.dir}" showoutput="yes" maxmemory="512m">
                 <sysproperty key="useLogging" value="false"/>
                 <sysproperty key="eclipselink.xml.platform" value="${xml.platform}"/>
                 <sysproperty key="parser" value="${parser}"/>
@@ -613,8 +617,9 @@
             <delete dir="${report.dir}/oxm/default" failonerror="false"/>
             <mkdir dir="${report.dir}/oxm/default"/>
             <mkdir dir="${build.dir}/${test.dir}"/>
-            <junit printsummary="yes" fork="true" dir="${build.dir}/${test.dir}" tempdir="${build.dir}/${test.dir}" showoutput="yes" maxmemory="512m">
+            <junit jvm="${test.junit.jvm.exec}" printsummary="yes" fork="true" dir="${build.dir}/${test.dir}" tempdir="${build.dir}/${test.dir}" showoutput="yes" maxmemory="512m">
                 <jvmarg value="-ea"/>
+                <jvmarg line="${additional.jvmargs}"/>
                 <sysproperty key="useLogging" value="false"/>
                 <sysproperty key="eclipselink.xml.platform" value="${xml.platform}"/>
                 <sysproperty key="parser" value="${parser}"/>
@@ -659,8 +664,9 @@
             <delete dir="${report.dir}/oxm/dom" failonerror="false"/>
             <mkdir dir="${report.dir}/oxm/dom"/>
             <mkdir dir="${build.dir}/${test.dir}"/>
-            <junit printsummary="yes" fork="true" dir="${build.dir}/${test.dir}" tempdir="${build.dir}/${test.dir}" showoutput="yes" maxmemory="512m">
+            <junit jvm="${test.junit.jvm.exec}" printsummary="yes" fork="true" dir="${build.dir}/${test.dir}" tempdir="${build.dir}/${test.dir}" showoutput="yes" maxmemory="512m">
                 <jvmarg value="-ea"/>
+                <jvmarg line="${additional.jvmargs}"/>
                 <sysproperty key="platformType" value="DOM"/>
                 <sysproperty key="metadataType" value="JAVA"/>
                 <sysproperty key="useLogging" value="false"/>
@@ -707,8 +713,9 @@
             <delete dir="${report.dir}/oxm/deploymentxml" failonerror="false"/>
             <mkdir dir="${report.dir}/oxm/deploymentxml"/>
             <mkdir dir="${build.dir}/${test.dir}"/>
-            <junit printsummary="yes" fork="true" dir="${build.dir}/${test.dir}" tempdir="${build.dir}/${test.dir}" showoutput="yes" maxmemory="512m">
+            <junit jvm="${test.junit.jvm.exec}" printsummary="yes" fork="true" dir="${build.dir}/${test.dir}" tempdir="${build.dir}/${test.dir}" showoutput="yes" maxmemory="512m">
                 <jvmarg value="-ea"/>
+                <jvmarg line="${additional.jvmargs}"/>
                 <sysproperty key="platformType" value="DOM"/>
                 <sysproperty key="metadataType" value="XML_ECLIPSELINK"/>
                 <sysproperty key="useLogging" value="false"/>
@@ -773,8 +780,9 @@
             <delete dir="${report.dir}/oxm/deploymentxml-tl" failonerror="false"/>
             <mkdir dir="${report.dir}/oxm/deploymentxml-tl"/>
             <mkdir dir="${build.dir}/${test.dir}"/>
-            <junit printsummary="yes" fork="true" dir="${build.dir}/${test.dir}" tempdir="${build.dir}/${test.dir}" showoutput="yes" maxmemory="512m">
+            <junit jvm="${test.junit.jvm.exec}" printsummary="yes" fork="true" dir="${build.dir}/${test.dir}" tempdir="${build.dir}/${test.dir}" showoutput="yes" maxmemory="512m">
                 <jvmarg value="-ea"/>
+                <jvmarg line="${additional.jvmargs}"/>
                 <sysproperty key="platformType" value="DOM"/>
                 <sysproperty key="metadataType" value="XML_TOPLINK"/>
                 <sysproperty key="useLogging" value="false"/>
@@ -835,8 +843,9 @@
             <delete dir="${report.dir}/oxm/docpres" failonerror="false"/>
             <mkdir dir="${report.dir}/oxm/docpres"/>
             <mkdir dir="${build.dir}/${test.dir}"/>
-            <junit printsummary="yes" fork="true" dir="${build.dir}/${test.dir}" tempdir="${build.dir}/${test.dir}" showoutput="yes" maxmemory="512m">
+            <junit jvm="${test.junit.jvm.exec}" printsummary="yes" fork="true" dir="${build.dir}/${test.dir}" tempdir="${build.dir}/${test.dir}" showoutput="yes" maxmemory="512m">
                 <jvmarg value="-ea"/>
+                <jvmarg line="${additional.jvmargs}"/>
                 <sysproperty key="platformType" value="DOC_PRES"/>
                 <sysproperty key="metadataType" value="JAVA"/>
                 <sysproperty key="useLogging" value="false"/>
diff --git a/sdo/eclipselink.sdo.test/antbuild.xml b/sdo/eclipselink.sdo.test/antbuild.xml
index a2f9b48..96a72a9 100644
--- a/sdo/eclipselink.sdo.test/antbuild.xml
+++ b/sdo/eclipselink.sdo.test/antbuild.xml
@@ -69,6 +69,10 @@
     <property name="jaxb-api.lib"   value="${sdotest.2.common.plugins.dir}/${jaxb-api.jar}"/>
     <property name="jacocoagent.lib" value="${extensions.depend.dir}/${jacocoagent.jar}"/>
 
+    <!-- JVM used to run tests -->
+    <property name="test.junit.jvm" value="${env.JAVA_HOME}"/>
+    <property name="test.junit.jvm.exec" value="${test.junit.jvm}/bin/java"/>
+
     <!-- path to OSGi Bundle compile dependencies -->
     <path id="sdotest.bundle.compile.path">
         <fileset
@@ -185,8 +189,9 @@
             <property name="additional.jvmargs" value="-Ddummy2=dummy"/>
             <!-- Fix for 290177 below removed temporarily to avoid out-of-memeory issues with LRG run -->
             <!-- junit printsummary="withOutAndErr" fork="yes" forkmode="once" dir="${resource.dir}" maxmemory="512m" showoutput="yes" -->
-            <junit printsummary="withOutAndErr" fork="yes" dir="${resource.dir}" maxmemory="512m" showoutput="yes">
+            <junit jvm="${test.junit.jvm.exec}" printsummary="withOutAndErr" fork="yes" dir="${resource.dir}" maxmemory="512m" showoutput="yes">
                 <jvmarg line="${additional.jvmargs}"/>
+                <env key="JAVA_HOME" value="${test.junit.jvm}"/>
                 <sysproperty key="loggingLevelFinest" value="false"/>
                 <sysproperty key="customContext" value="@{customcontext}"/>
                 <sysproperty key="eclipselink.xml.platform" value="${xml.platform}"/>
diff --git a/utils/eclipselink.dbws.builder.test/antbuild.xml b/utils/eclipselink.dbws.builder.test/antbuild.xml
index 8f75913..9c6cb8d 100644
--- a/utils/eclipselink.dbws.builder.test/antbuild.xml
+++ b/utils/eclipselink.dbws.builder.test/antbuild.xml
@@ -79,6 +79,10 @@
     <property file="${user.home}/test.properties"/>
     <property file="${dbwsbldrtest.build.location}/test.properties"/>
 
+    <!-- JVM used to run tests -->
+    <property name="test.junit.jvm" value="${env.JAVA_HOME}"/>
+    <property name="test.junit.jvm.exec" value="${test.junit.jvm}/bin/java"/>
+
     <!-- Primary Targets: "jar" separate for dev use -->
     <target name="build" depends="clean, compile, package" description="build dbwsbldrtests jar"/>
     <target name="test"  depends="build, run-tests"        description="run tests after building"/>
@@ -261,6 +265,7 @@
         <!-- Can be set e.g. in test.properties to add VM options for a particular platform/driver  -->
         <property name="additional.jvmargs" value="-Ddummy2=dummy"/>
         <junit
+          jvm="${test.junit.jvm.exec}"
           printsummary="withOutAndErr"
           fork="yes"
           forkmode="once"