import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
+import java.util.concurrent.TimeUnit;
import jalview.util.ChannelProperties;
import jalview.util.LaunchUtils;
String jvmmempc = null;
String jvmmemmax = null;
boolean debug = false;
- boolean help = false;
+ boolean wait = true;
boolean quiet = false;
+ // must set --debug before --launcher...
boolean launcherstop = false;
boolean launcherprint = false;
+ boolean launcherwait = false;
ArrayList<String> arguments = new ArrayList<>();
for (String arg : args)
{
{
quiet = true;
}
- if (arg.equals("--help") || arg.startsWith("--help-"))
- {
- help = true;
- }
- if (arg.equals("--launcherprint"))
+ if (debug && arg.equals("--launcherprint"))
{
launcherprint = true;
}
- if (arg.equals("--launcherstop"))
+ if (debug && arg.equals("--launcherstop"))
{
launcherstop = true;
}
+ if (debug && arg.equals("--launcherwait"))
+ {
+ launcherwait = true;
+ }
+ // these quite immediately
+ if (arg.equals("--version") || arg.equals("--help")
+ || arg.startsWith("--help-")
+ || (debug && arg.equals("--launchernowait")))
+ {
+ wait = false;
+ }
+ // Don't add the --launcher... args to Jalview launch
+ if (arg.startsWith("--launcher"))
+ {
+ continue;
+ }
// jvmmempc and jvmmemmax args used to set memory and are not passed on to
// startClass
if (arg.startsWith(
String scalePropertyArg = HiDPISetting.getScalePropertyArg();
if (scalePropertyArg != null)
{
- if (debug && !quiet)
- {
- System.out.println("Running " + startClass + " with scale setting "
- + scalePropertyArg);
- }
+ sysout(debug, quiet, "Running " + startClass + " with scale setting "
+ + scalePropertyArg);
command.add(scalePropertyArg);
}
final ProcessBuilder builder = new ProcessBuilder(command);
- if (!quiet && (Boolean
- .parseBoolean(System.getProperty("launcherprint", "false"))
- || (debug && launcherprint)))
+ if ((Boolean.parseBoolean(System.getProperty("launcherprint", "false"))
+ || launcherprint))
{
- System.out.println(
+ sysout(debug, quiet,
"LAUNCHER COMMAND: " + String.join(" ", builder.command()));
}
- if (debug && !quiet)
- {
- System.out.println("Running " + startClass + " with "
- + (memSetting == null ? "no memory setting"
- : ("memory setting " + memSetting)));
- }
+ sysout(debug, quiet,
+ "Running " + startClass + " with "
+ + (memSetting == null ? "no memory setting"
+ : ("memory setting " + memSetting)));
if (Boolean.parseBoolean(System.getProperty("launcherstop", "false"))
|| (debug && launcherstop))
{
- if (!quiet)
- {
- System.out.println(
- "System property 'launcherstop' is set and not 'false'. Exiting.");
- }
+ sysout(debug, quiet,
+ "System property 'launcherstop' is set and not 'false'. Exiting.");
System.exit(0);
}
try
{
builder.inheritIO();
Process process = builder.start();
- process.waitFor();
+ if (wait || launcherwait)
+ {
+ sysout(debug, quiet, "Launching application process");
+ process.waitFor();
+ }
+ else
+ {
+ int waitInt = 0;
+ sysout(debug, quiet,
+ "Wait time for application process is " + waitInt + "ms");
+ process.waitFor(waitInt, TimeUnit.MILLISECONDS);
+ }
+ sysout(debug, quiet, "Launcher process ending");
} catch (IOException e)
{
if (e.getMessage().toLowerCase(Locale.ROOT).contains("memory"))
}
}
+ private static void sysout(boolean debug, boolean quiet, String message)
+ {
+ if (debug && !quiet)
+ {
+ System.out.println("LAUNCHERDEBUG - " + message);
+ }
+ }
+
}