Java 为可执行 Jar 文件设置图标
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19927509/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Set Icon for executable Jar file
提问by Peter Penzov
I have a simple executable Jar file. How I can set icon for this file? In my case I use the standard Jar icon which I would like to change.
我有一个简单的可执行 Jar 文件。我如何为这个文件设置图标?就我而言,我使用了我想更改的标准 Jar 图标。
回答by tokhi
you can use setIconImage
:
你可以使用setIconImage
:
frame.setIconImage(
new ImageIcon(getClass().getClassLoader().getResource("PATH/TO/YourImage.png"))
);
Update
更新
If you want to change the coffee-cup
then you may use tools like JSmoothto create executable java file and also change the jar file icon.
如果你想改变,coffee-cup
那么你可以使用像JSmooth这样的工具来创建可执行的 java 文件并更改 jar 文件图标。
As you can see in the comments JSmooth
can be used for windows operating systems. For Mac
you can check the link hereon how to change the icon.
正如您在评论中看到的,JSmooth
可用于 windows 操作系统。因为Mac
您可以在此处查看有关如何更改图标的链接。
For linux
OS you can create a desktop launcher
and choose an icon image for it.
对于linux
操作系统,您可以创建一个桌面launcher
并为其选择一个图标图像。
回答by Prasad
One of my friends suggested me about JSmoothwhich can be used to associate icon to a jar file.
我的一位朋友向我推荐了JSmooth,它可用于将图标与 jar 文件相关联。
You can try this.
你可以试试这个。
Edit:
编辑:
But this will work only for Windows OS.
但这仅适用于 Windows 操作系统。
PS: This tool can be used to convert jar to exe and then you can set icon to it.
PS:此工具可用于将jar转换为exe,然后您可以为其设置图标。