+ // new
+ boolean headlessArg = false;
+
+ try
+ {
+ String logLevel = null;
+ if (bootstrapArgs.contains(Arg.TRACE))
+ {
+ logLevel = "TRACE";
+ }
+ else if (bootstrapArgs.contains(Arg.DEBUG))
+ {
+ logLevel = "DEBUG";
+ }
+ if (logLevel == null && !(bootstrapProperties == null))
+ {
+ logLevel = bootstrapProperties.getProperty(Cache.JALVIEWLOGLEVEL);
+ }
+ Console.initLogger(logLevel);
+ } catch (NoClassDefFoundError error)
+ {
+ error.printStackTrace();
+ String message = "\nEssential logging libraries not found."
+ + "\nUse: java -classpath \"$PATH_TO_LIB$/*:$PATH_TO_CLASSES$\" jalview.bin.Jalview";
+ Jalview.exit(message, 0);
+ }
+
+ // register SIGTERM listener
+ Runtime.getRuntime().addShutdownHook(new Thread()
+ {
+ public void run()
+ {
+ Console.debug("Running shutdown hook");
+ QuitHandler.startForceQuit();
+ boolean closeExternal = Cache
+ .getDefault("DEFAULT_CLOSE_EXTERNAL_VIEWERS", false)
+ || Cache.getDefault("ALWAYS_CLOSE_EXTERNAL_VIEWERS", false);
+ StructureViewerBase.setQuitClose(closeExternal);
+ if (desktop != null)
+ {
+ for (JInternalFrame frame : Desktop.desktop.getAllFrames())
+ {
+ if (frame instanceof StructureViewerBase)
+ {
+ ((StructureViewerBase) frame).closeViewer(closeExternal);
+ }
+ }
+ }
+
+ if (QuitHandler.gotQuitResponse() == QResponse.CANCEL_QUIT)
+ {
+ // Got to here by a SIGTERM signal.
+ // Note we will not actually cancel the quit from here -- it's too
+ // late -- but we can wait for saving files and close external viewers
+ // if configured.
+ // Close viewers/Leave viewers open
+ Console.debug("Checking for saving files");
+ QuitHandler.getQuitResponse(false);
+ }
+ else
+ {
+ Console.debug("Nothing more to do");
+ }
+ Console.debug("Exiting, bye!");
+ // shutdownHook cannot be cancelled, JVM will now halt
+ }
+ });
+
+ String usrPropsFile = bootstrapArgs.contains(Arg.PROPS)
+ ? bootstrapArgs.getValue(Arg.PROPS)
+ : aparser.getValue("props");
+ // if usrPropsFile == null, loadProperties will use the Channel
+ // preferences.file
+ Cache.loadProperties(usrPropsFile);
+ if (usrPropsFile != null)
+ {
+ System.out.println(
+ "CMD [-props " + usrPropsFile + "] executed successfully!");
+ testoutput(bootstrapArgs, Arg.PROPS,
+ "test/jalview/bin/testProps.jvprops", usrPropsFile);
+ }
+
+ // --argfile=... -- OVERRIDES ALL NON-BOOTSTRAP ARGS
+ if (bootstrapArgs.contains(Arg.ARGFILE))
+ {
+ argparser = ArgParser.parseArgFiles(
+ bootstrapArgs.getValueList(Arg.ARGFILE),
+ bootstrapArgs.getBoolean(Arg.INITSUBSTITUTIONS),
+ bootstrapArgs);
+ }
+ else
+ {
+ argparser = new ArgParser(args,
+ bootstrapArgs.getBoolean(Arg.INITSUBSTITUTIONS),
+ bootstrapArgs);
+ }
+
+ if (!Platform.isJS())
+ /**
+ * Java only
+ *
+ * @j2sIgnore
+ */
+ {
+ if (bootstrapArgs.contains(Arg.HELP))
+ {
+ List<Map.Entry<Type, String>> helpArgs = bootstrapArgs
+ .getList(Arg.HELP);
+ System.out.println(Arg.usage(helpArgs.stream().map(e -> e.getKey())
+ .collect(Collectors.toList())));
+ Jalview.exit(null, 0);
+ }
+ if (aparser.contains("help") || aparser.contains("h"))
+ {
+ /*
+ * Now using new usage statement.
+ showUsage();
+ */
+ System.out.println(Arg.usage());
+ Jalview.exit(null, 0);
+ }
+
+ // new CLI
+ headlessArg = bootstrapArgs.isHeadless();
+ if (headlessArg)
+ {
+ System.setProperty("java.awt.headless", "true");
+ }
+ // old CLI
+ if (aparser.contains("nodisplay") || aparser.contains("nogui")
+ || aparser.contains("headless"))
+ {
+ System.setProperty("java.awt.headless", "true");
+ headless = true;
+ }
+ // anything else!
+
+ // allow https handshakes to download intermediate certs if necessary
+ System.setProperty("com.sun.security.enableAIAcaIssuers", "true");
+
+ String jabawsUrl = bootstrapArgs.getValue(Arg.JABAWS);
+ if (jabawsUrl == null)
+ jabawsUrl = aparser.getValue("jabaws");
+ if (jabawsUrl != null)
+ {
+ try
+ {
+ Jws2Discoverer.getDiscoverer().setPreferredUrl(jabawsUrl);
+ System.out.println(
+ "CMD [-jabaws " + jabawsUrl + "] executed successfully!");
+ testoutput(bootstrapArgs, Arg.JABAWS,
+ "http://www.compbio.dundee.ac.uk/jabaws", jabawsUrl);
+ } catch (MalformedURLException e)
+ {
+ System.err.println(
+ "Invalid jabaws parameter: " + jabawsUrl + " ignored");
+ }
+ }
+ }