Merge branch 'spike/relaunch_memsetingds' into spikes/jim
authorJim Procter <jprocter@issues.jalview.org>
Mon, 17 Sep 2018 08:47:52 +0000 (09:47 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Mon, 17 Sep 2018 08:47:52 +0000 (09:47 +0100)
merged classpath discovery with refactored Jalview launcher

1  2 
src/jalview/bin/Jalview.java
test/jalview/bin/CommandLineOperations.java

Simple merge
@@@ -60,95 -58,21 +61,40 @@@ public class CommandLineOperation
  
    private ArrayList<String> successfulCMDs = new ArrayList<>();
  
-   /***
-    * from
-    * http://stackoverflow.com/questions/808276/how-to-add-a-timeout-value-when
-    * -using-javas-runtime-exec
-    * 
-    * @author jimp
-    * 
-    */
-   private static class Worker extends Thread
-   {
-     private final Process process;
-     private BufferedReader outputReader;
-     private BufferedReader errorReader;
-     private Integer exit;
-     private Worker(Process process)
-     {
-       this.process = process;
-     }
-     @Override
-     public void run()
-     {
-       try
-       {
-         exit = process.waitFor();
-       } catch (InterruptedException ignore)
-       {
-         return;
-       }
-     }
-     public BufferedReader getOutputReader()
-     {
-       return outputReader;
-     }
-     public void setOutputReader(BufferedReader outputReader)
-     {
-       this.outputReader = outputReader;
-     }
-     public BufferedReader getErrorReader()
-     {
-       return errorReader;
-     }
-     public void setErrorReader(BufferedReader errorReader)
-     {
-       this.errorReader = errorReader;
-     }
-   }
 -  private Worker jalviewDesktopRunner(boolean withAwt, String cmd,
 -          int timeout)
 +
 +  private static ClassGraph scanner = null;
 +
 +  private static String classpath = null;
 +
 +  public synchronized static String getClassPath()
    {
 -    String cp_sep = ":";
 -    if (System.getProperty("os.name").indexOf("Windows") >= 0)
 +    if (scanner == null)
      {
 -      cp_sep = ";";
 +      scanner = new ClassGraph();
 +      ScanResult scan = scanner.scan();
 +      classpath = scan.getClasspath();
      }
 +    while (classpath == null)
 +    {
 +      try
 +      {
 +        Thread.sleep(10);
 +      } catch (InterruptedException x)
 +      {
 +
 +      }
 +    }
 +    return classpath;
 +  }
 +  private Worker jalviewDesktopRunner(boolean withAwt, 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" : "")
 -            + " -classpath ./classes" + cp_sep
 -            + "./lib/* jalview.bin.Jalview ";
 -    System.out.println("CMD [" + cmd + "]");
 +            + " -classpath " + classpath + " jalview.bin.Jalview ";
      Process ls2_proc = null;
      Worker worker = null;
      try