I want to be able to set the dock:name of my Java application on a Mac.
I know that I can do it through the -Xdock:name="Xyz" option to the Java VM, but I would like to do it directly in my program.
According to this question it can be done by setting the "com.apple.mrj.application.apple.menu.about.name" property, but I simply cannot get that to work.
Consider this program:
import javax.swing.*;
public class Abc extends JFrame {
public Abc() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(200, 200);
setVisible(true);
}
public static void main(String[] args) {
try {
System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Xyz");
System.setProperty("apple.laf.useScreenMenuBar", "true");
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch(Exception e) {
System.out.println("Exception: " + e.getMessage());
}
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new Abc();
}
});
}
}
I would have expected that to work, but it doesn't. I'm using OS X 10.8.2 (Mountain Lion) and Java 1.7.0_09, both of which are very new versions. Perhaps the API has changed?
What am I doing wrong?