Programmatically setting the dock:name Java Mac OS X JVM property

ksullivan picture ksullivan · Mar 31, 2010 · Viewed 8.9k times · Source

Is there a programatic alternative to setting the dock:name Java Mac OS X property by doing

java -Xdock:name="My App Name" -jar myapp.jar

, or is this the only way to set the dock:name property?

Answer

Matt Solnit picture Matt Solnit · Apr 1, 2010

It's been a while, but I believe you need to do the following (this is assuming you're using Swing):

  1. Put your main() method in a separate class from the JFrame.
  2. Before creating the JFrame, set the "com.apple.mrj.application.apple.menu.about.name" system property.

For example:

public class Launcher {
  public static void main(String[] args) {
    System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Hello World!");
    JFrame jframe = new MyJFrame();
    jframe.setVisible(true);
  }
}