diff --git a/build.gradle b/build.gradle index 53ca2e7f..71752404 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ if(System.getProperty("os.arch") == "aarch64") { osArch = "aarch64" targetName = "-" + osArch } -def headless = GraphicsEnvironment.isHeadless() +def headless = "true".equals(System.getProperty("java.awt.headless")) || GraphicsEnvironment.isHeadless() group "com.sparrowwallet" version "${sparrowVersion}" diff --git a/buildSrc/src/main/java/org/openjfx/gradle/JavaFXPlatform.java b/buildSrc/src/main/java/org/openjfx/gradle/JavaFXPlatform.java index 00d9dae7..9ea59914 100644 --- a/buildSrc/src/main/java/org/openjfx/gradle/JavaFXPlatform.java +++ b/buildSrc/src/main/java/org/openjfx/gradle/JavaFXPlatform.java @@ -66,7 +66,7 @@ public enum JavaFXPlatform { String osClassifier = project.getExtensions().getByType(OsDetector.class).getClassifier(); - if(GraphicsEnvironment.isHeadless()) { + if("true".equals(System.getProperty("java.awt.headless")) || GraphicsEnvironment.isHeadless()) { osClassifier += "-monocle"; } diff --git a/src/main/java/com/sparrowwallet/sparrow/Interface.java b/src/main/java/com/sparrowwallet/sparrow/Interface.java index 90a1ff57..ef2c73fe 100644 --- a/src/main/java/com/sparrowwallet/sparrow/Interface.java +++ b/src/main/java/com/sparrowwallet/sparrow/Interface.java @@ -7,10 +7,13 @@ public enum Interface { public static Interface get() { if(currentInterface == null) { - if(java.awt.GraphicsEnvironment.isHeadless()) { - if("Monocle".equalsIgnoreCase(System.getProperty("glass.platform"))) { - currentInterface = TERMINAL; - } else { + boolean headless = java.awt.GraphicsEnvironment.isHeadless(); + boolean monocle = "Monocle".equalsIgnoreCase(System.getProperty("glass.platform")); + + if(headless || monocle) { + currentInterface = TERMINAL; + + if(headless && !monocle) { throw new UnsupportedOperationException("Headless environment detected but Monocle platform not found"); } } else {