2

I guess many people think this question has duplicated ones. However, this question precisely asks

how can I run Java where !GraphicsEnvironment.isHeadless() returns true

The answer would be like

java --gui=disabled -jar hoge.jar
kensuke1984
  • 691
  • 7
  • 17

1 Answers1

1

The commandline parameter -Djava.awt.headless=true can be used to set the headless mode from the commandline.

The linked question shows ways to set it programmatically, which is somewhat trickier but may be preferrable if you don't want or can't access the commandline parameters.

Kayaman
  • 67,952
  • 3
  • 69
  • 110