How can I prevent java processes from stealing focus?

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

How can I prevent java processes from doing this in OS X?


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.

(also posted to stackoverflow).