From d7ec1baa6020072d1f552c7b81d07dd144da0ddf Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Mon, 26 Nov 2018 13:26:33 -0800 Subject: [PATCH] Avoid using UI if we're in a headless JVM. Closes #131. --- CHANGELOG.md | 4 ++++ .../java/com/threerings/getdown/launcher/Getdown.java | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f461c6..c121829 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ Getdown. They must be prefixed by `sys.`: for example `sys.silent = true` will set the `silent` system property to `true`. +* If Getdown is run in a headless JVM, it will avoid showing a UI but will attempt to install and + launch the application anyhow. Note that passing `-Dsilent` will override this behavior (because + in silent mode the default is only to install the app, not also launch it). + * Fixed issue with `appid` not being properly used when specified via command line arg. * Fixed issue with running Getdown on single CPU systems (or virtual systems). It was attempting to diff --git a/launcher/src/main/java/com/threerings/getdown/launcher/Getdown.java b/launcher/src/main/java/com/threerings/getdown/launcher/Getdown.java index b3c6cff..17368b1 100644 --- a/launcher/src/main/java/com/threerings/getdown/launcher/Getdown.java +++ b/launcher/src/main/java/com/threerings/getdown/launcher/Getdown.java @@ -9,6 +9,7 @@ import java.awt.BorderLayout; import java.awt.Container; import java.awt.Dimension; import java.awt.EventQueue; +import java.awt.GraphicsEnvironment; import java.awt.Image; import java.awt.event.ActionEvent; import java.awt.image.BufferedImage; @@ -67,6 +68,13 @@ public abstract class Getdown extends Thread if (_silent) { _launchInSilent = SysProps.launchInSilent(); } + // If we're running in a headless environment and have not otherwise customized + // silence, operate without a UI and do launch the app. + if (!_silent && GraphicsEnvironment.isHeadless()) { + log.info("Running in headless JVM, will attempt to operate without UI."); + _silent = true; + _launchInSilent = true; + } _delay = SysProps.startDelay(); } catch (SecurityException se) { // don't freak out, just assume non-silent and no delay; we're probably already