APEXCORE-817 Specifying full path for the java command line programs
diff --git a/engine/src/test/java/com/datatorrent/stram/StramLocalClusterTest.java b/engine/src/test/java/com/datatorrent/stram/StramLocalClusterTest.java
index 56641f8..fd475c8 100644
--- a/engine/src/test/java/com/datatorrent/stram/StramLocalClusterTest.java
+++ b/engine/src/test/java/com/datatorrent/stram/StramLocalClusterTest.java
@@ -60,7 +60,7 @@
 import com.datatorrent.stram.plan.physical.PTOperator;
 import com.datatorrent.stram.support.ManualScheduledExecutorService;
 import com.datatorrent.stram.support.StramTestSupport;
-
+import com.datatorrent.stram.util.VersionInfo;
 
 public class StramLocalClusterTest
 {
@@ -381,14 +381,18 @@
     String sourceDir = "src/test/resources/dynamicJar/";
     String destDir = testMeta.getPath();
 
+    // The compiled java class should be loadable by the current java runtime hence setting the compile target version
+    // to be the same
+    String binLocation = getJavaBinLocation();
+
     Process p = Runtime.getRuntime()
-        .exec(new String[] {"javac", "-d", destDir, sourceDir + pojoClassName + ".java"}, null, null);
+        .exec(new String[] {binLocation + "javac", "-d", destDir, sourceDir + pojoClassName + ".java"}, null, null);
     IOUtils.copy(p.getInputStream(), System.out);
     IOUtils.copy(p.getErrorStream(), System.err);
     Assert.assertEquals(0, p.waitFor());
 
     p = Runtime.getRuntime()
-        .exec(new String[] {"jar", "-cf", pojoClassName + ".jar", pojoClassName + ".class"}, null, new File(destDir));
+        .exec(new String[] {binLocation + "jar", "-cf", pojoClassName + ".jar", pojoClassName + ".class"}, null, new File(destDir));
     IOUtils.copy(p.getInputStream(), System.out);
     IOUtils.copy(p.getErrorStream(), System.err);
     Assert.assertEquals(0, p.waitFor());
@@ -396,6 +400,12 @@
     return new File(destDir, pojoClassName + ".jar").getAbsolutePath();
   }
 
+  private String getJavaBinLocation()
+  {
+    String javaHome = System.getProperty("java.home");
+    return VersionInfo.compare(System.getProperty("java.version"), "1.9") < 0 ? javaHome + "/../bin/" : javaHome + "/bin/";
+  }
+
   @Test
   public void testAppPath() throws Exception
   {