12

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?

Cœur
  • 37,241
  • 25
  • 195
  • 267
ksullivan
  • 496
  • 1
  • 7
  • 12

2 Answers2

8

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);
  }
}
Matt Solnit
  • 32,152
  • 8
  • 53
  • 57
  • Hah -- looks like I answered this question a while back: http://stackoverflow.com/questions/307024/native-swing-menu-bar-support-for-macos-x-in-java – Matt Solnit Apr 01 '10 at 15:43
  • 12
    Looks like this is no longer working on newer versions of OS X and/or Java. It gets ignored for me on Java 1.7 and 1.8 on OS X 10.9. The `-Xdock:name` option to the `java` command seems to be the replacement technique. – Andrew Janke Mar 19 '14 at 04:42
1

The Apple extensions are documented here: http://developer.apple.com/mac/library/documentation/Java/Reference/1.5.0/appledoc/api/overview-summary.html

I looked at com.apple.eawt.Application, which gives you access to the icon and menus... but not title, unfortunately.

I am guessing the prescribed approach is to roll out your own App Bundle, as detailed here: http://developer.apple.com/Mac/library/documentation/Java/Conceptual/Java14Development/03-JavaDeployment/JavaDeployment.html

Dilum Ranatunga
  • 13,254
  • 3
  • 41
  • 52