+ }
+ }).start();
+ }
+
+ public synchronized boolean allFinished()
+ {
+ return queued == 0 && running == 0;
+ }
+
+ }
+
+ public static Jalview getInstance()
+ {
+ return instance;
+ }
+
+ /**
+ * main class for Jalview application
+ *
+ * @param args
+ * open <em>filename</em>
+ */
+ public static void main(String[] args)
+ {
+ instance = new Jalview();
+ instance.doMain(args);
+ }
+
+ /**
+ * @param args
+ */
+ void doMain(String[] args)
+ {
+ System.setSecurityManager(null);
+ System.out
+ .println("Java version: " + System.getProperty("java.version"));
+ System.out.println("Java Home: " + System.getProperty("java.home"));
+ System.out.println(System.getProperty("os.arch") + " "
+ + System.getProperty("os.name") + " "
+ + System.getProperty("os.version"));
+ String val = System.getProperty("sys.install4jVersion");
+ if (val != null)
+ {
+ System.out.println("Install4j version: " + val);
+ }
+ val = System.getProperty("installer_template_version");
+ if (val != null)
+ {
+ System.out.println("Install4j template version: " + val);
+ }
+ val = System.getProperty("launcher_version");
+ if (val != null)
+ {
+ System.out.println("Launcher version: " + val);
+ }
+
+ // report Jalview version
+ Cache.loadBuildProperties(true);
+
+ ArgsParser aparser = new ArgsParser(args);
+ boolean headless = false;
+
+ if (aparser.contains("help") || aparser.contains("h"))
+ {
+ showUsage();
+ System.exit(0);
+ }
+ if (aparser.contains("nodisplay") || aparser.contains("nogui")
+ || aparser.contains("headless"))
+ {
+ System.setProperty("java.awt.headless", "true");
+ headless = true;
+ }
+ String usrPropsFile = aparser.getValue("props");
+ Cache.loadProperties(usrPropsFile); // must do this before
+ if (usrPropsFile != null)
+ {
+ System.out.println(
+ "CMD [-props " + usrPropsFile + "] executed successfully!");
+ }
+
+ // anything else!
+
+ final String jabawsUrl = aparser.getValue("jabaws");
+ if (jabawsUrl != null)
+ {
+ try
+ {
+ Jws2Discoverer.getDiscoverer().setPreferredUrl(jabawsUrl);
+ System.out.println(
+ "CMD [-jabaws " + jabawsUrl + "] executed successfully!");
+ } catch (MalformedURLException e)
+ {
+ System.err.println(
+ "Invalid jabaws parameter: " + jabawsUrl + " ignored");
+ }
+ }
+
+ String defs = aparser.getValue("setprop");
+ while (defs != null)
+ {
+ int p = defs.indexOf('=');
+ if (p == -1)
+ {
+ System.err.println("Ignoring invalid setprop argument : " + defs);
+ }
+ else
+ {
+ System.out.println("Executing setprop argument: " + defs);
+ // DISABLED FOR SECURITY REASONS
+ // TODO: add a property to allow properties to be overriden by cli args
+ // Cache.setProperty(defs.substring(0,p), defs.substring(p+1));
+ }
+ defs = aparser.getValue("setprop");
+ }
+ if (System.getProperty("java.awt.headless") != null
+ && System.getProperty("java.awt.headless").equals("true"))
+ {
+ headless = true;
+ }
+ System.setProperty("http.agent",
+ "Jalview Desktop/" + Cache.getDefault("VERSION", "Unknown"));
+ try
+ {
+ Cache.initLogger();
+ } catch (NoClassDefFoundError error)
+ {
+ error.printStackTrace();
+ System.out.println("\nEssential logging libraries not found."
+ + "\nUse: java -classpath \"$PATH_TO_LIB$/*:$PATH_TO_CLASSES$\" jalview.bin.Jalview");
+ System.exit(0);
+ }
+
+ desktop = null;
+
+ setLookAndFeel();
+
+ /*
+ * configure 'full' SO model if preferences say to, else use the default (SO
+ * Lite)
+ */
+ if (Cache.getDefault("USE_FULL_SO", true))
+ {
+ SequenceOntologyFactory.setInstance(new SequenceOntology());
+ }
+
+ if (!headless)
+ {
+
+ desktop = new Desktop();
+ desktop.setInBatchMode(true); // indicate we are starting up
+
+ try
+ {
+ JalviewTaskbar.setTaskbar(this);
+ } catch (Exception e)
+ {
+ Cache.log.info("Cannot set Taskbar");
+ Cache.log.error(e.getMessage());
+ // e.printStackTrace();
+ } catch (Throwable t)
+ {
+ Cache.log.info("Cannot set Taskbar");
+ Cache.log.error(t.getMessage());
+ // t.printStackTrace();
+ }
+
+ desktop.setVisible(true);
+ desktop.startServiceDiscovery();
+ if (!aparser.contains("nousagestats"))
+ {
+ startUsageStats(desktop);
+ }
+ else
+ {
+ System.err.println("CMD [-nousagestats] executed successfully!");
+ }
+
+ if (!aparser.contains("noquestionnaire"))
+ {
+ String url = aparser.getValue("questionnaire");
+ if (url != null)
+ {
+ // Start the desktop questionnaire prompter with the specified
+ // questionnaire
+ Cache.log.debug("Starting questionnaire url at " + url);
+ desktop.checkForQuestionnaire(url);
+ System.out.println(
+ "CMD questionnaire[-" + url + "] executed successfully!");
+ }
+ else
+ {
+ if (Cache.getProperty("NOQUESTIONNAIRES") == null)