Tag Archives: note to self

Headless Java Process

Someone1 has updated things on OSX so that when a Java process runs it spawns a little coffee cup icon in the task bar which then steals focus. I’m sure whoever did this thought it would be a wonderful idea which no doubt has some benefits if you think really really hard. If, on the other hand, you’re a dev with a build process that spawns JUnit as a forked process many times during the course of the build, then this new behaviour can be considered a tad on the annoying side. Thankfully a quick moan at Google yielded the following magic:

-Djava.awt.headless=true

I’ve added this little gem into our build scripts by using:

<junit printsummary="on" haltonfailure="true" fork="yes">
    <jvmarg value="-Djava.awt.headless=true" />
    :    :    :
</junit>

And I even hear rumour that you can set export JAVA_TOOL_OPTIONS='-Djava.awt.headless=true', although that’s uncorroborated hearsay at the moment – depends how many scripts I need to update as to whether I go for the global solution.


1Oracle, I’m looking at you… and Apple, don’t think I don’t hold you at least partly responsible.