JAL-3253-applet headless branch - just experimenting.
[jalview.git] / test / jalview / bin / CommandLineOperations.java
index c7b1d53..f770757 100644 (file)
@@ -144,23 +144,41 @@ public class CommandLineOperations
     return classpath;
   }
 
-  private Worker getJalviewDesktopRunner(boolean withAwt, String cmd,
+  private Worker getJalviewDesktopRunner(boolean headless, String cmd,
           int timeout)
   {
     // Note: JAL-3065 - don't include quotes for lib/* because the arguments are
     // not expanded by the shell
     String classpath = getClassPath();
     String _cmd = "java "
-            + (withAwt ? "-Djava.awt.headless=true" : "")
+            + (headless ? "-Djava.awt.headless=true" : "")
             + " -classpath " + classpath + " jalview.bin.Jalview ";
     Process ls2_proc = null;
     Worker worker = null;
+
+    System.out.println("Executing " + _cmd + cmd);
     try
     {
       ls2_proc = Runtime.getRuntime().exec(_cmd + cmd);
     } catch (Throwable e1)
     {
       e1.printStackTrace();
+
+      String path = "%Java_HOME%/bin/java " + _cmd + cmd;
+
+      try
+      {
+
+        ProcessBuilder builder = new ProcessBuilder(path);
+        builder.redirectErrorStream(true);
+        ls2_proc = builder.start();
+
+      } catch (IOException e)
+      {
+        String s = e.getMessage();
+        System.out.println(s);
+      }
+
     }
     if (ls2_proc != null)
     {
@@ -183,6 +201,12 @@ public class CommandLineOperations
     return worker;
   }
 
+  private void startProcess()
+  {
+
+
+  }
+
   @BeforeTest(alwaysRun = true)
   public void initialize()
   {
@@ -212,7 +236,7 @@ public class CommandLineOperations
   @BeforeTest(alwaysRun = true)
   public void setUpForCommandLineInputOperations() throws IOException
   {
-    String cmds = "-open examples/uniref50.fa -noquestionnaire -nousagestats";
+    String cmds = "headless -open examples/uniref50.fa -noquestionnaire -nousagestats";
     Worker worker = getJalviewDesktopRunner(false, cmds, SETUP_TIMEOUT);
     String ln = null;
     int count = 0;