+ System.err
+ .println("Ignoring invalid setprop argument : " + setprop);
+ }
+ else
+ {
+ jalview.bin.Console
+ .errPrintln("Executing setprop argument: " + setprop);
+ if (Platform.isJS())
+ {
+ Cache.setProperty(setprop.substring(0, p),
+ setprop.substring(p + 1));
+ }
+ // DISABLED FOR SECURITY REASONS
+ // TODO: add a property to allow properties to be overriden by cli args
+ // Cache.setProperty(setprop.substring(0,p), setprop.substring(p+1));
+ }
+ }
+ if (System.getProperty("java.awt.headless") != null
+ && System.getProperty("java.awt.headless").equals("true"))
+ {
+ headless = true;
+ }
+ System.setProperty("http.agent", HttpUtils.getUserAgent());
+
+ try
+ {
+ Console.initLogger();
+ } 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, ExitCode.NO_LOGGING);
+ }
+ desktop = null;
+
+ if (!(headless || headlessArg))
+ setLookAndFeel();
+
+ /*
+ * configure 'full' SO model if preferences say to, else use the default (full
+ * SO) - as JS currently doesn't have OBO parsing, it must use 'Lite' version
+ */
+ boolean soDefault = !Platform.isJS();
+ if (Cache.getDefault("USE_FULL_SO", soDefault))
+ {
+ SequenceOntologyFactory.setInstance(new SequenceOntology());
+ }
+
+ if (!(headless || headlessArg))
+ {
+ Desktop.nosplash = "false".equals(bootstrapArgs.getValue(Arg.SPLASH))
+ || aparser.contains("nosplash")
+ || Cache.getDefault("SPLASH", "true").equals("false");
+ desktop = new Desktop();
+ desktop.setInBatchMode(true); // indicate we are starting up
+
+ mixedCliWarning();
+
+ try
+ {
+ JalviewTaskbar.setTaskbar(this);
+ } catch (Exception e)
+ {
+ Console.info("Cannot set Taskbar");
+ Console.error(e.getMessage());
+ // e.printStackTrace();
+ } catch (Throwable t)
+ {
+ Console.info("Cannot set Taskbar");
+ Console.error(t.getMessage());
+ // t.printStackTrace();
+ }
+
+ // set Proxy settings before all the internet calls
+ Cache.setProxyPropertiesFromPreferences();
+
+ desktop.setVisible(true);
+
+ if (!Platform.isJS())
+ /**
+ * Java only
+ *
+ * @j2sIgnore
+ */
+ {
+
+ /**
+ * Check to see that the JVM version being run is suitable for the Java
+ * version this Jalview was compiled for. Popup a warning if not.
+ */
+ if (!LaunchUtils.checkJavaVersion())
+ {
+ Console.warn("The Java version being used (Java "
+ + LaunchUtils.getJavaVersion()
+ + ") may lead to problems. This installation of Jalview should be used with Java "
+ + LaunchUtils.getJavaCompileVersion() + ".");
+
+ if (!LaunchUtils
+ .getBooleanUserPreference("IGNORE_JVM_WARNING_POPUP"))
+ {
+ Object[] options = {
+ MessageManager.getString("label.continue") };
+ JOptionPane.showOptionDialog(null,
+ MessageManager.formatMessage(
+ "warning.wrong_jvm_version_message",
+ LaunchUtils.getJavaVersion(),
+ LaunchUtils.getJavaCompileVersion()),
+ MessageManager
+ .getString("warning.wrong_jvm_version_title"),
+ JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE,
+ null, options, options[0]);
+ }
+ }
+
+ boolean webservicediscovery = bootstrapArgs
+ .getBoolean(Arg.WEBSERVICEDISCOVERY);
+ if (aparser.contains("nowebservicediscovery"))
+ webservicediscovery = false;
+ if (webservicediscovery)
+ {
+ desktop.startServiceDiscovery();
+ }
+ else
+ {
+ testoutput(argparser, Arg.WEBSERVICEDISCOVERY);
+ }
+
+ boolean usagestats = !bootstrapArgs.getBoolean(Arg.NOUSAGESTATS);
+ if (aparser.contains("nousagestats"))
+ usagestats = false;
+ if (usagestats)
+ {
+ startUsageStats(desktop);
+ testoutput(argparser, Arg.NOUSAGESTATS);
+ }
+ else
+ {
+ Console.outPrintln("CMD [-nousagestats] executed successfully!");
+ testoutput(argparser, Arg.NOUSAGESTATS);
+ }
+
+ boolean questionnaire = bootstrapArgs.getBoolean(Arg.QUESTIONNAIRE);
+ if (aparser.contains("noquestionnaire"))
+ questionnaire = false;
+ if (questionnaire)
+ {
+ String url = aparser.getValue("questionnaire");
+ if (url != null)
+ {
+ // Start the desktop questionnaire prompter with the specified
+ // questionnaire
+ Console.debug("Starting questionnaire url at " + url);
+ desktop.checkForQuestionnaire(url);
+ Console.outPrintln("CMD questionnaire[-" + url
+ + "] executed successfully!");
+ }
+ else
+ {
+ if (Cache.getProperty("NOQUESTIONNAIRES") == null)
+ {
+ // Start the desktop questionnaire prompter with the specified
+ // questionnaire
+ // String defurl =
+ // "http://anaplog.compbio.dundee.ac.uk/cgi-bin/questionnaire.pl";
+ // //
+ String defurl = "https://www.jalview.org/cgi-bin/questionnaire.pl";
+ Console.debug(
+ "Starting questionnaire with default url: " + defurl);
+ desktop.checkForQuestionnaire(defurl);
+ }
+ }
+ }
+ else
+ {
+ Console.outPrintln(
+ "CMD [-noquestionnaire] executed successfully!");
+ testoutput(argparser, Arg.QUESTIONNAIRE);
+ }
+
+ if ((!aparser.contains("nonews")
+ && Cache.getProperty("NONEWS") == null
+ && !"false".equals(bootstrapArgs.getValue(Arg.NEWS)))
+ || "true".equals(bootstrapArgs.getValue(Arg.NEWS)))
+ {
+ desktop.checkForNews();
+ }
+
+ if (!aparser.contains("nohtmltemplates")
+ && Cache.getProperty("NOHTMLTEMPLATES") == null)
+ {
+ BioJsHTMLOutput.updateBioJS();
+ }
+ }
+ }
+ else
+ {
+
+ if (getArgParser().isMixedStyle())
+ {
+ String warning = MessageManager.formatMessage(
+ "warning.using_mixed_command_line_arguments",
+ getArgParser().getMixedExamples());
+ Console.warn(warning);
+ Jalview.exit(
+ "Exiting due to mixed old and new command line arguments",
+ ExitCode.INVALID_ARGUMENT);
+ }
+ if (getArgParser().isOldStyle())
+ {
+ String warning = MessageManager
+ .getString("warning.using_old_command_line_arguments")
+ .replace("\n", " ")
+ + "https://www.jalview.org/help/html/features/commandline.html";
+ Console.warn(warning);
+ }
+
+ }
+
+ // Run Commands from cli
+ boolean commandsSuccess = false;
+ if (!(argparser.isMixedStyle() || argparser.isOldStyle()))
+ {
+ cmds = new Commands(argparser, headlessArg);
+ cmds.processArgs();
+ commandsSuccess = cmds.argsWereParsed();
+
+ if (commandsSuccess)
+ {
+ if (headlessArg)
+ {
+ if (argparser.getBoolean(Arg.NOQUIT))
+ {
+ Console.warn("Completed " + Arg.HEADLESS.getName()
+ + " commands, but " + Arg.NOQUIT
+ + " is set so not quitting!");
+ }
+ else
+ {
+ Jalview.exit("Successfully completed commands in headless mode",
+ ExitCode.OK);
+ }
+ }
+ Console.info("Successfully completed commands");
+ }
+ else
+ {
+ if (headlessArg)
+ {
+ Jalview.exit("Error when running Commands in headless mode",
+ ExitCode.ERROR_RUNNING_COMMANDS);
+ }
+ Console.warn("Error when running commands");
+ }
+ }
+
+ // Check if JVM and compile version might cause problems and log if it
+ // might.
+ if (headless && !Platform.isJS() && !LaunchUtils.checkJavaVersion())
+ {
+ Console.warn("The Java version being used (Java "
+ + LaunchUtils.getJavaVersion()
+ + ") may lead to problems. This installation of Jalview should be used with Java "
+ + LaunchUtils.getJavaCompileVersion() + ".");
+ }
+
+ String file = null, data = null;
+
+ FileFormatI format = null;
+
+ DataSourceType protocol = null;
+
+ FileLoader fileLoader = new FileLoader(!headless);
+
+ String groovyscript = null; // script to execute after all loading is
+ // completed one way or another
+ // extract groovy argument and execute if necessary
+ groovyscript = aparser.getValue("groovy", true);
+ file = aparser.getValue("open", true);
+
+ if (file == null && desktop == null && !commandsSuccess)
+ {
+ Jalview.exit("No files to open!", ExitCode.NO_FILES);
+ }
+
+ long progress = -1;
+ // Finally, deal with the remaining input data.
+ if (file != null)
+ {
+ if (!headless)
+ {
+ desktop.setProgressBar(
+ MessageManager
+ .getString("status.processing_commandline_args"),
+ progress = IdUtils.newId(IdType.PROGRESS));
+ }
+ Console.outPrintln("CMD [-open " + file + "] executed successfully!");
+
+ if (!Platform.isJS())
+ /**
+ * ignore in JavaScript -- can't just file existence - could load it?
+ *
+ * @j2sIgnore
+ */
+ {
+ if (!HttpUtils.startsWithHttpOrHttps(file))