如何更改Mac OS X启动板中显示的Java应用程序名称 [英] How to change the Java application name shown in the Mac OS X launchpad

查看:397
本文介绍了如何更改Mac OS X启动板中显示的Java应用程序名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我的 Java SWT 编写的应用程序在 OS X ,都来自 Eclipse jar ,它在启动板中的名称是java,就像如图所示。

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.

在我的开头代码我调用 Display.setAppName(MyApp),菜单栏和菜单项中的应用程序名称是正确的,它读取 MyApp 关于MyApp 配置MyApp 等。菜单项表现正常,我可以接收并处理适当的事件。
因此问题仅与启动板中显示的应用程序名称有关。有没有办法在不创建应用程序包的情况下以编程方式设置正确的名称,以便以编程方式显示?

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.代码实际上是在JVM下运行的,它是在我的代码中使用 ProcessBuilder 启动的:

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();

一种递归,需要在启动应用程序之前以编程方式计算一些jvm选项和类路径。

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

推荐答案

您应该使用jar创建一个macOS应用程序包,您可以在其中将包显示名称放在<$ c $中c> Info.plist 捆绑包的文件。这是Oracle详细记录的( http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/packagingAppsForMac.html

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).

Apple也记录了Java应用程序包的结构: https://developer.apple.com/library/content/documentation/Java/Conceptual/Java14Development/03-JavaDeployment/JavaDeployment.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

这篇关于如何更改Mac OS X启动板中显示的Java应用程序名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆