在 Linux 可执行文件中嵌入图标

发布于 2024-08-19 04:19:42 字数 634 浏览 2 评论 0原文

我用 Java 编写了一个应用程序,并使用 gcj 成功编译了它。

在 (X)ubuntu 的文件管理器中,我的应用程序显示为默认的 Linux 可执行图标,我想用我自己的图标替换它。

我看到其他应用程序将自定义图标显示为可执行文件,例如 Firefox,但不知道如何解决该问题。 Linux 二进制文件有某种资源编辑器吗?

桌面条目

我尝试创建一个执行应用程序的桌面条目文件,如下所示:

[Desktop Entry]
Version=1.0
Type=Application
Name=MyJavaApp
Comment=
Exec=./MyJavaApp
Path=./../../libs/
Terminal=true
Icon=./icon.png
X-KDE-Library=./../../libs/libswt.so

双击它会使终端弹出并再次消失,仅此而已。我相当确定该应用程序不会启动,因为它找不到所需的 SWT 库。我希望在终端中看到输出,但我无法从那里启动它。

此外,Ubuntu 似乎不承认 Icon。我尝试过各种分辨率的PNG;没有骰子。

I have written an application in Java and succesfully compiled it using gcj.

In (X)ubuntu's File Manager, my application appears with the default Linux executable icon, which I would like to replace with my own.

I have seen that other applications display a custom icon as the executable, such as Firefox, but have no idea how to approach the problem. Is there some sort of resource editor for Linux binaries?

Desktop Entry

I've tried creating a Desktop Entry file that executes the application as follows:

[Desktop Entry]
Version=1.0
Type=Application
Name=MyJavaApp
Comment=
Exec=./MyJavaApp
Path=./../../libs/
Terminal=true
Icon=./icon.png
X-KDE-Library=./../../libs/libswt.so

Double-clicking it makes a terminal pop up and disappear again, and that's it. I'm fairly sure the application doesn't launch because it can't find the required SWT library. I was hoping to see the output in the terminal, but I can't launch it from there.

Furthermore, Ubuntu doesn't seem to acknowledge Icon. I have tried various resolution PNGs; no dice.

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

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

发布评论

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

评论(3

冷默言语 2024-08-26 04:19:42

Linux 上的可执行文件没有嵌入图标(尝试将文件管理器指向 /usr/bin)。您所看到的可能是桌面条目。这是一个描述图标、程序名称和可执行文件的文本文件。

Executables on Linux do not have icons embedded (try to point your file manager to /usr/bin). What you have seen is probably a Desktop Entry. That's a text file describing the icon, program name and the executable.

无风消散 2024-08-26 04:19:42

在 Ubuntu 上:

鼠标右键单击您不喜欢的图标 ->属性->在打开的窗口中单击图标 ->选择你想要的图标

On Ubuntu:

mouse right click the icon you don't like -> Properties -> in the opened window click the icon -> choose an icon you want

不气馁 2024-08-26 04:19:42

您不能使用 ~ userhome, .在这里,..在桌面文件的文件路径中。您必须给出 / root 的完整文件路径。

将所有相关文件路径添加到 $PATH 环境变量中,然后只需在桌面条目中给出文件名,例如:

Exec=MyJavaApp
Icon=MyJavaPic.png

You cannot use ~ userhome, . here, .. up in file paths in desktop files. You must give the complete filepath from / root.
OR
Add all the pertinent filepaths to the $PATH environment variable, then just give the filenames in the desktop entries, e.g.:

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