15
votes

I'm starting a runnable jar from a java app ( also headless runnable jar). Tried both Runtime.getRuntime().exec() and ProcesBuilder method. The process gets launched just fine, but on the Mac ( 10.6 ) it shows the name of the jar I'm starting in the main menu bar and also puts in the dock Is there a way to prevent that ? Interestingly, if you start a jar with java -jar from the command line the jar name does not appear in the menu bar or process dock. Any ideas? Thanks Andy

2

2 Answers

31
votes

To enable it globally instead of adding the option to each process, set the JAVA_TOOL_OPTIONS variable like this in your .bashrc/.zshrc start up script.

export JAVA_TOOL_OPTIONS='-Djava.awt.headless=true'

Reference here:

http://docs.oracle.com/javase/7/docs/webnotes/tsg/TSG-VM/html/envvars.html

11
votes

Are you passing java.awt.headless=true? Try adding this to your process:

java -Djava.awt.headless=true