0

On a PC, this issue would not arise, but I have a mac and the java menu bars typically appear on the top left hand area of the screen. For example (from the apple developers website):

enter image description here

The blue highlighted menu is the same name as the main class in a java program. I was wondering how I could name my main method class with a space in between two words rather than an underscore.

Artjom B.
  • 61,146
  • 24
  • 125
  • 222
iProgramIt
  • 54
  • 1
  • 2
  • 11
  • 1
    It's not your main method that determines this. If you look at [this](https://developer.apple.com/library/mac/documentation/java/conceptual/java14development/07-nativeplatformintegration/nativeplatformintegration.html), it can be changed via the -Xdock command line parameter or from within the plistfile – MadProgrammer Jul 27 '14 at 03:30
  • You could also look at [this](http://stackoverflow.com/questions/2553941/programatically-setting-the-dockname-java-mac-os-x-jvm-property) – MadProgrammer Jul 27 '14 at 03:46

1 Answers1

1

I tried...

  • Using the -Xdock:name="My App Name" on the command line
  • System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Not My Mac App"); within the main method before before and after setting the look and feel

Only -Xdock:name worked.

Tested using Java 8 on 10.9.4, so the settings might be different for earlier version of Java and OS combinations

You may also consider creating a proper Mac .app bundle, which should allow you to set these properties via the plist file...

Take a look at Packaging a Java App for Distribution on a Mac. It is "slightly" out of date, but should lead you in the right direction

MadProgrammer
  • 343,457
  • 22
  • 230
  • 366