问题
I know there are a lot of questions similar to mine, but I actually couldn't solve my problem even after reading all of them. I have a Java application that as soon as it starts it goes on tray. The problem is on Mac, because only there the icon is in the tray bar AND in the Dock. I want to get rid of the Dock icon.
I did already a number of trials: try to wrap my jar in a ".app" folder and writing an Info.plist file. I inserted the LSUIElement and set it to "1" or to "true". This hides the application Icon, but shows an ugly grey icon terminal-like that remains in the terminal.
Tell me even if you have any ideas or other ways to bypass this. thankyou.
回答1:
You may be using the wrong property name for what you want. Have a look here:
https://developer.apple.com/library/mac/#documentation/Java/Reference/Java_PropertiesRef/Articles/JavaSystemProperties.html
The property you want to set is, I think:
"apple.awt.UIElement" (not "LSUIElement")
There are two ways you can do that. You can pass:
-Dapple.awt.UIElement="true"
as a VM argument, or you can set a property in the Info.plist as:
<key>Properties</key>
<dict>
<key>apple.awt.UIElement</key>
<string>true</string>
</dict>
来源:https://stackoverflow.com/questions/8246766/how-to-hide-the-java-swt-program-icon-in-the-dock-when-the-application-is-in-the