如何更改默认的 jar 图标

发布于 2024-09-27 01:18:08 字数 195 浏览 1 评论 0原文

首先我已经阅读了有关该主题的所有问题,因此这不是重复的问题。

我想问的是,用Java编写的应用程序(例如eclipse)如何使用图标而不是默认的jar图标。

我不关心兼容性,我总是可以为 Windows 和 Linux 制作 2 个不同版本的程序。

如何在 Linux 和 Windows 中制作它。

非常感谢。

First I have read all questions about this subject, so this is not a repeated question.

What I want to ask about, how an application written in Java (such as eclipse) uses an icon instead of the default jar icons.

I don't care about compatibility, I always can make 2 different versions of my program to Windows and Linux.

How to make it in Linux and Windows.

Thanks very much.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

划一舟意中人 2024-10-04 01:18:08

对于像 eclipse 这样的程序,它是用 java 编写的,并且在 Windows(或 Linux 或 Mac)中具有特定的图标,它们实际上有一个操作系统特定的可执行文件,例如 windows 的 eclipse.exe,它初始化 java程序。

该可执行文件包含应用程序图标,而不是 Java 程序。如果您想做同样的事情,您需要创建可执行文件“前门”,并给它一个图标。

如果只是为了自己的个人审美,只需创建jar文件的快捷方式并更改快捷方式的图标即可。

In the case of programs like eclipse, which are written in java and have a specific icon in Windows (or Linux or Mac for that matter), they actually have an OS specific executable file, e.g. eclipse.exe for windows, that initialises the java program.

It is this executable that contains the application icon, not the Java program. If you want to do the same, you'll need to create the executable 'front door', as it were, and give it an icon.

If it's just for your own personal aesthetics, just create a short cut to the jar file and change the icon of the shortcut.

柏拉图鍀咏恒 2024-10-04 01:18:08

要为 MAC 设置图像,您可以使用 com.apple.eawt.Application。尝试一下:

Image img = new ImageIcon("abc.png").getImage();  // your desired image  
Application app = Application.getApplication();
app.setDockIconImage(img);

但是,默认情况下这不会在 Windows 或 Linux 上构建。如果您愿意,(Maven) 将以下依赖项添加到您的 POM:

<dependency>
    <groupId>com.yuvimasory</groupId>
    <artifactId>orange-extensions</artifactId>
    <version>1.3.0</version>
</dependency>

或者,如果您不使用 Maven,您可以从 http://central.maven.org/maven2/ 下载 JAR com/yuvimasory/orange-extensions/1.3.0/orange-extensions-1.3.0.jar

To set an image for MAC, you can use com.apple.eawt.Application. try this:

Image img = new ImageIcon("abc.png").getImage();  // your desired image  
Application app = Application.getApplication();
app.setDockIconImage(img);

However, this will not build on Windows or Linux by default. If you'd like it to, (Maven) add the following dependency to your POM:

<dependency>
    <groupId>com.yuvimasory</groupId>
    <artifactId>orange-extensions</artifactId>
    <version>1.3.0</version>
</dependency>

Or, if you don't use Maven, you can download the JAR from http://central.maven.org/maven2/com/yuvimasory/orange-extensions/1.3.0/orange-extensions-1.3.0.jar

云归处 2024-10-04 01:18:08

如果应用程序是使用 Java Web Start 启动的,则应用程序图标可以是指定用于桌面快捷方式和菜单项。

请注意,此图标并未直接附加到 Jar,但由于最终用户永远不会看到或不必处理 Jar,因此这应该不是问题。

If the application is launched using Java Web Start, an application icon can be specified for use in desktop shortcuts and menu items.

Note that this icon is not attached directly to the Jar, but since the end user never sees or has to deal with a Jar, that should not be a problem.

茶花眉 2024-10-04 01:18:08

我使用 NetBeans,所以如果您没有使用它,我不太知道。但是,当您选择窗口时,属性窗口中有一个图标文件的选项。当您构建 .jar 时,该图标应该与程序一起内置。

I use NetBeans, so if you aren't using that, I don't quite know. But, when you select the window, there is an option in the properties window for an icon file. When you build the .jar, that icon should be built in with the program.

凯凯我们等你回来 2024-10-04 01:18:08

如果您谈论的是 Windows 中的实际应用程序图标,则无法(以编程方式)更改它。这是由操作系统决定的。尽管您可以在操作系统的文件夹选项中更改它。

但是,您可以使用 setIconImage() 设置窗口(读取:JFrame)图标图像。

If you're talking about the actual application icon in, say, Windows, you can't change it (programmatically). That's determined by the OS. Although you can change it in your OS in Folder Options.

You can, however, set the window (read: JFrame) icon image using setIconImage().

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文