Skip to content
Advertisement

Swing application menu name not displaying correctly in Java 1.8

Okay, so I’ve done Swing applications before, and I know if you want to display a different name for the application menu (the one on Macs that usually have a “Preferences” and “Quit” option), you have to use: System.setProperty("com.apple.mrj.application.apple.menu.about.name", "App name"); and it must be executed before the JFrame is created. I’ve done this, but it continues to show my Main class’ name as the menu name, as if I didn’t write that line of code at all. I googled for this issue, but couldn’t find anything useful, and then I just searched on here, but everyone who had a similar issue was running Java 1.5, 1.6, or 1.7. So I thought maybe it had something to do with my current Java version, 1.8.

This, this, and this did not work. This, this, and this either sent me to outdated info, or the links didn’t work anymore. Also, I’m running Mac 10.8.

Any suggestions/answers would be greatly appreciated.

An update:

here is the code I originally had:

JavaScript

And here is a solution that trashgod provided to someone else:

JavaScript

And apparently I need 10 reputation to post images, so I can’t show you the result, but it didn’t work out.

Advertisement

Answer

Using Java 8 on Mac OS X 10.9, setting the System property

JavaScript

appears to be ineffectual in changing the name displayed in the application menu. Alternatives that still work include these:

  • By default, the application menu will display the simple name of the class specified in the java command line or the Main-Class attribute of the JAR’s manifest.

    JavaScript
  • Use the -Xdock:name="Name" command line parameter.

    JavaScript
  • Add the application JAR to a Mac application bundle, as shown here, an add the attribute to the Info.plist.

    JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement