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?

2 Answers 2

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.

1
  • 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 Mar 3, 2017 at 21:29
2

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

export MAVEN_OPTS=-Djava.awt.headless=true

1
  • 1
    this is not good enough, you need to pass it to sub processes in maven as well. Jun 7, 2012 at 13:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.