Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the Java application name shown in the Mac OS X launchpad

When my application written in Java with SWT runs under OS X, both from under Eclipse and from jar, its name in the launchpad reads "java", like shown in the picture.

wrong app name shown in the launchpad

In the beginning of my code I call Display.setAppName("MyApp"), and the name of the application in the menu bar and menu items is correct, it reads MyApp, About MyApp, Configure MyApp, etc. The menu items behave properly, I can receive and handle the appropriate events. So the problem pertains exclusively to the app name, shown in the launchpad. Is there any way to set the correct name to be shown in the launchpad programmatically, from the code, without creation of the application bundle?

P. S. The code is actually running under JVM that is started from within my code using ProcessBuilder:

  new ProcessBuilder("java -cp mypath MyClass my args").start();

a kind of recursion, needed to compute some jvm options and classpaths programmatically before starting the application.

like image 594
m. vokhm Avatar asked Feb 18 '17 19:02

m. vokhm


2 Answers

The only answer that worked for me is here. In short:

Using JDK8, you can set the apple.awt.application.name property to affect the Application menu name.

However, Martijn Courteaux’s warning that you must do this before any AWT classes are loaded still applies. And AWT classes will be loaded before your main() method runs if it lives in a subclass of JFrame.

In other words, set apple.awt.application.name and do it before creating the JFrame.

P.S. If you're trying to change the dock application title, this command might work:

java -Xdock:name=Alfabet

like image 172
ReinstateMonica3167040 Avatar answered Sep 20 '22 09:09

ReinstateMonica3167040


You should create a macOS app bundle with your jar, where you can put the bundle display name in the Info.plist file of the bundle.This is well documented by Oracle (http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/packagingAppsForMac.html).

The structure of a Java app bundle is documented by Apple as well: https://developer.apple.com/library/content/documentation/Java/Conceptual/Java14Development/03-JavaDeployment/JavaDeployment.html

like image 39
clemens Avatar answered Sep 23 '22 09:09

clemens