16

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

4

2 回答 2

32

要全局启用它而不是向每个进程添加选项,请在 .bashrc/.zshrc 启动脚本中像这样设置 JAVA_TOOL_OPTIONS 变量。

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

参考这里:

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

于 2013-07-30T15:52:56.843 回答
11

你路过java.awt.headless=true吗?尝试将此添加到您的流程中:

java -Djava.awt.headless=true

于 2013-04-01T21:23:56.417 回答