//import edu.stanford.ejalbert.launching.IBrowserLaunching;
import groovy.lang.Binding;
import groovy.util.GroovyScriptEngine;
-import jalview.bin.ArgParser.Arg;
-import jalview.bin.ArgParser.BootstrapArgs;
+import jalview.bin.argparser.Arg;
+import jalview.bin.argparser.ArgParser;
+import jalview.bin.argparser.BootstrapArgs;
import jalview.ext.so.SequenceOntology;
import jalview.gui.AlignFrame;
import jalview.gui.Desktop;
System.setSecurityManager(null);
}
+ // Move any new getdown-launcher-new.jar into place over old
+ // getdown-launcher.jar
+ String appdirString = System.getProperty("getdownappdir");
+ if (appdirString != null && appdirString.length() > 0)
+ {
+ final File appdir = new File(appdirString);
+ new Thread()
+ {
+ @Override
+ public void run()
+ {
+ LaunchUtil.upgradeGetdown(
+ new File(appdir, "getdown-launcher-old.jar"),
+ new File(appdir, "getdown-launcher.jar"),
+ new File(appdir, "getdown-launcher-new.jar"));
+ }
+ }.start();
+ }
+
// get args needed before proper ArgParser
BootstrapArgs bootstrapArgs = BootstrapArgs.getBootstrapArgs(args);
} 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);
+ 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
String usrPropsFile = bootstrapArgs.contains(Arg.PROPS)
? bootstrapArgs.get(Arg.PROPS)
: aparser.getValue("props");
+ // if usrPropsFile == null, loadProperties will use the Channel
+ // preferences.file
Cache.loadProperties(usrPropsFile);
if (usrPropsFile != null)
{
|| argparser.getBool(Arg.HELP))
{
showUsage();
- System.exit(0);
+ Jalview.exit(null, 0);
}
if (bootstrapArgs.contains(Arg.HEADLESS))
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);
+ String message = "\nEssential logging libraries not found."
+ + "\nUse: java -classpath \"$PATH_TO_LIB$/*:$PATH_TO_CLASSES$\" jalview.bin.Jalview";
+ Jalview.exit(message, 0);
}
desktop = null;
if (!(headless || headlessArg))
{
- Desktop.nosplash = aparser.contains("nosplash");
+ Desktop.nosplash = "false".equals(bootstrapArgs.get(Arg.SPLASH))
+ || aparser.contains("nosplash");
desktop = new Desktop();
desktop.setInBatchMode(true); // indicate we are starting up
.println("CMD [-noquestionnaire] executed successfully!");
}
- if (!aparser.contains("nonews")
- || Cache.getProperty("NONEWS") == null)
+ if ((!aparser.contains("nonews")
+ && Cache.getProperty("NONEWS") == null
+ && !"false".equals(bootstrapArgs.get(Arg.NEWS)))
+ || "true".equals(bootstrapArgs.get(Arg.NEWS)))
{
desktop.checkForNews();
}
if (!aparser.contains("nohtmltemplates")
- || Cache.getProperty("NOHTMLTEMPLATES") == null)
+ && Cache.getProperty("NOHTMLTEMPLATES") == null)
{
BioJsHTMLOutput.updateBioJS();
}
boolean commandsSuccess = cmds.argsWereParsed();
if (commandsSuccess)
{
- Console.info("Successfully completed commands");
if (headlessArg)
{
- System.out.println("#### EXITING");
- System.exit(0);
+ Jalview.exit("Successfully completed commands in headless mode", 0);
}
+ Console.info("Successfully completed commands");
}
else
{
- Console.warn("Error when running commands");
if (headlessArg)
- System.exit(1);
+ {
+ Jalview.exit("Error when running Commands in headless mode", 1);
+ }
+ Console.warn("Error when running commands");
}
// Check if JVM and compile version might cause problems and log if it
+ LaunchUtils.getJavaCompileVersion() + ".");
}
- // Move any new getdown-launcher-new.jar into place over old
- // getdown-launcher.jar
- String appdirString = System.getProperty("getdownappdir");
- if (appdirString != null && appdirString.length() > 0)
- {
- final File appdir = new File(appdirString);
- new Thread()
- {
- @Override
- public void run()
- {
- LaunchUtil.upgradeGetdown(
- new File(appdir, "getdown-launcher-old.jar"),
- new File(appdir, "getdown-launcher.jar"),
- new File(appdir, "getdown-launcher-new.jar"));
- }
- }.start();
- }
-
String file = null, data = null;
FileFormatI format = null;
groovyscript = aparser.getValue("groovy", true);
file = aparser.getValue("open", true);
- if (file == null && desktop == null)
+ if (file == null && desktop == null && !commandsSuccess)
{
- System.out.println("No files to open!");
- System.exit(1);
+ Jalview.exit("No files to open!", 1);
}
long progress = -1;
{
if (!(new File(file)).exists())
{
- System.out.println("Can't find " + file);
if (headless)
{
- System.exit(1);
+ Jalview.exit(
+ "Can't find file '" + file + "' in headless mode", 1);
}
+ Console.warn("Can't find file'" + file + "'");
}
}
}
private static boolean setLinuxLookAndFeel()
{
boolean set = false;
- /*
- * THIS IS A TEST FOR THE BUILD SERVER!
- *
- set = setMetalLookAndFeel();
- //set = setFlatLookAndFeel();
- */
+ set = setFlatLookAndFeel();
if (!set)
set = setMetalLookAndFeel();
// avoid GtkLookAndFeel -- not good results especially on HiDPI
public void quit()
{
// System.exit will run the shutdownHook first
- System.out.println("Quitting now. Bye!");
- System.exit(0);
+ Jalview.exit("Quitting now. Bye!", 0);
}
public static AlignFrame getCurrentAlignFrame()
{
return cmds;
}
+
+ public static void exit(String message, int exitcode)
+ {
+ Console.debug("Using Jalview.exit");
+ if (message != null)
+ if (exitcode == 0)
+ Console.info(message);
+ else
+ Console.error(message);
+ if (exitcode > -1)
+ System.exit(exitcode);
+ }
}