JAL-3830 Look for --headless mode and add -Djava.awt.headless=true to java invocation...
[jalview.git] / utils / getdown / bin / jalview.sh
index 9e3a8c7..c1ad597 100755 (executable)
@@ -36,6 +36,15 @@ if [ "$( uname -s )" = "Darwin" ]; then
   ISMACOS=1
 fi
 
+# check for headless mode
+HEADLESS=0
+for ARG in ARGS; do
+  if [ "${ARG}" = "--headless" ]; then
+    HEADLESS=1
+    break
+  fi
+done
+
 declare -a JVMARGS=()
 
 # set vars for being inside the macos App Bundle
@@ -57,6 +66,11 @@ else
   JAVA="${APPDIR}/jre/bin/java"
 fi
 
+if [ "${HEADLESS}" = 1 ]; then
+  # this suppresses the Java icon appearing in the macOS Dock and maybe other things in other OSes
+  JVMARGS=( "${JVMARGS[@]}" "-Djava.awt.headless=true" )
+fi
+
 SYSJAVA=java
 GETDOWNTXT="${APPDIR}/getdown.txt"