20

Has anyone else noticed that their command line java applications in OSX create GUI processes that steal focus(ie, groovy, maven sub processes)? I'm finding it extremely annoying; probably b/c I've been living with it for like 6-8 months since I think OSX v10.6?

How can I prevent java processes from doing this in OSX?

dsummersl
  • 6,588
  • 50
  • 65

2 Answers2

26

Eventually I found the basic solution:

For Java applications in general you can specify that they are 'headless', by adding the option -Djava.awt.headless=true to your java application.

dsummersl
  • 6,588
  • 50
  • 65
  • 1
    I found that the order mattered in my case. I was calling `java -jar /path/to/my.jar -Djava.awt.headless=true`. Changed to `java -Djava.awt.headless=true -jar /path/to/my.jar` and it fixed it. `java version "1.8.0_72"` `Darwin 15.0.0 Darwin Kernel Version 15.0.0: Sat Sep 19 15:53:46 PDT` `2015; root:xnu-3247.10.11~1/RELEASE_X86_64 x86_64 i386` – Will Charlton Mar 03 '17 at 21:29
2

Add to your shell configuration, e.g., .bashrc:

export MAVEN_OPTS=-Djava.awt.headless=true

bobfoster
  • 59
  • 3