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