ADC Home > Reference Library > Technical Q&As > Java > Porting >

Server Processes and the Dock


Q: My Java application runs as a background process, but as soon as I make an AWT call, an icon appears in the Dock. This allows the current user to quit the server from the Finder, or on logout. How do I prevent this?

A: In Java 1.4.1 on Mac OS X, initialization of the AWT prompts creation of an AppKit (Cocoa) runloop, which automatically creates, among other things, an Application menu and a Dock icon. This is typically a problem for shell script-based server apps that are trying to run independent of a logged-in user, because the new Dock entry is now under the control of the current user.

To prevent this situation, you'll need to run your application in headless mode, a new feature of Java 1.4. Setting the java.awt.headless system property to true will allow your application to use AWT resources without this undesirable side effect. Some minor code changes may be needed to handle any HeadlessException cases that will arise. Please see Sun's notes on Headless Support for details on using headless support in your Java application.


[Jan 19, 2004]


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.