X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fbin%2FLauncher.java;h=20a466b422338e8d76ca775ede8e91f60cab2630;hb=ed379d3f998a6aea83ce8c9cdaab2ec8234adb6a;hp=2155f8d17ac268353f129aa2f9449dc788833a84;hpb=7f0a4109670acd7b68b4f1d38c99da4f1dde608e;p=jalview.git diff --git a/src/jalview/bin/Launcher.java b/src/jalview/bin/Launcher.java index 2155f8d..20a466b 100644 --- a/src/jalview/bin/Launcher.java +++ b/src/jalview/bin/Launcher.java @@ -50,8 +50,7 @@ public class Launcher { private final static String startClass = "jalview.bin.Jalview"; - private final static String dockIconPath = ChannelProperties - .getProperty("logo.512"); + private final static String headlessProperty = "java.awt.headless"; /** * main method for jalview.bin.Launcher. This restarts the same JRE's JVM with @@ -71,29 +70,13 @@ public class Launcher + LaunchUtils.getJavaCompileVersion() + "."); } - final String javaBin = System.getProperty("java.home") + File.separator - + "bin" + File.separator + "java"; - - List command = new ArrayList<>(); - command.add(javaBin); - - String memSetting = null; - - boolean isAMac = System.getProperty("os.name").indexOf("Mac") > -1; - - for (String jvmArg : ManagementFactory.getRuntimeMXBean() - .getInputArguments()) - { - command.add(jvmArg); - } - command.add("-cp"); - command.add(ManagementFactory.getRuntimeMXBean().getClassPath()); - String jvmmempc = null; String jvmmemmax = null; boolean debug = false; boolean wait = true; boolean quiet = false; + boolean headless = false; + boolean gui = false; // must set --debug before --launcher... boolean launcherstop = false; boolean launcherprint = false; @@ -109,6 +92,14 @@ public class Launcher { quiet = true; } + if (arg.equals("--headless")) + { + headless = true; + } + if (arg.equals("--gui")) + { + gui = true; + } if (debug && arg.equals("--launcherprint")) { launcherprint = true; @@ -121,10 +112,8 @@ public class Launcher { launcherwait = true; } - // these quite immediately - if (arg.equals("--version") || arg.equals("--help") - || arg.startsWith("--help-") - || (debug && arg.equals("--launchernowait"))) + // this ends the launcher immediately + if (debug && arg.equals("--launchernowait")) { wait = false; } @@ -168,6 +157,29 @@ public class Launcher arguments.add(arg); } } + if (gui) + { + // --gui takes precedence over --headless + headless = false; + } + + final String appName = ChannelProperties.getProperty("app_name"); + + // if we're using jalview.bin.Launcher we always assume a console is in use + final String javaBin = LaunchUtils.findJavaBin(true); + + List command = new ArrayList<>(); + command.add(javaBin); + + String memSetting = null; + + for (String jvmArg : ManagementFactory.getRuntimeMXBean() + .getInputArguments()) + { + command.add(jvmArg); + } + command.add("-cp"); + command.add(ManagementFactory.getRuntimeMXBean().getClassPath()); // use saved preferences if no cmdline args boolean useCustomisedSettings = LaunchUtils @@ -190,6 +202,7 @@ public class Launcher boolean memSet = false; boolean dockIcon = false; boolean dockName = false; + boolean headlessProp = false; for (int i = 0; i < command.size(); i++) { String arg = command.get(i); @@ -210,6 +223,10 @@ public class Launcher { dockName = true; } + else if (arg.startsWith("-D" + headlessProperty + "=")) + { + headlessProp = true; + } } if (!memSet) @@ -224,26 +241,32 @@ public class Launcher } } - if (isAMac) + if (LaunchUtils.isMac) { if (!dockIcon) { + String dockIconPath = System.getProperty("getdownappdir", ".") + + File.separator + "resource/jalview_logo.png"; command.add("-Xdock:icon=" + dockIconPath); } if (!dockName) { // -Xdock:name=... doesn't actually work :( // Leaving it in in case it gets fixed - command.add( - "-Xdock:name=" + ChannelProperties.getProperty("app_name")); + command.add("-Xdock:name=" + appName); // this launches WITHOUT an icon in the macOS dock. Could be useful for // getdown? // command.add("-Dapple.awt.UIElement=false"); // This also does not work for the dock command.add("-Dcom.apple.mrj.application.apple.menu.about.name=" - + ChannelProperties.getProperty("app_name")); + + appName); } } + if (headless && !headlessProp) + { + System.setProperty(headlessProperty, "true"); + command.add("-D" + headlessProperty + "=true"); + } String scalePropertyArg = HiDPISetting.getScalePropertyArg(); if (scalePropertyArg != null)