up previous next contents
Up: java-on-mac Previous: A note on using Next: About that font ...   Contents

The dock icon

If you're running your Java application from a shell script you can add two Mac JVM command-line arguments that let you accomplish two things:

  1. You can associate the name of your application with your icon in the Mac OS X Dock.
  2. You can provide a custom icon for your application in the Mac OS X Dock.

As an example, if I just run my application like this:

java -cp wikitex.jar:. \
     com.devdaily.wikitex.Main

my application icon in the Dock will look like Figure 12.1:

Figure 12.1: This shows the icon in the Dock for a "typical" Java application.
Image 11-dock-before

But, if I modify that script to add in two Dock-specific parameters, like this:

java -cp wikitex.jar:. \
     -Xdock:name="WikiTeX" \
     -Xdock:icon=wikitex-icon.jpg \
     com.devdaily.wikitex.Main

I can make the Dock icon look like Figure 12.2:

Figure 12.2: This shows my Java application icon in the Dock after I added two parameters.
Image 12-dock-after

This is very cool, because it shows both (a) my application name and (b) my application icon (okay, just a picture of a cat), and not the crummy default stuff. This really helps the application look like a native Mac OS X application.

(Note: The picture of the cat has nothing to do with my application. It is just a cute picture I pulled from icanhascheezburger.com.)