How to change executable jar file icon?

和自甴很熟 提交于 2019-12-17 09:40:05

问题


I have been able to change the runtime icon using this example like this

getFrame().setIconImage(Toolkit.getDefaultToolkit().getImage(getClass()
.getClassLoader().getResource("MyProject/resources/myIcon.png")));

but is there a way to tell NetBeans to use myIcon.png for the executable jar file (MyProject/dist/MyProject.jar) icon?


回答1:


A launch wrapper is the solution, I use launch4j, a cross platform lightweight wrapper

launch4j website




回答2:


You may use JSmooth to create executable java file and also associate icon to it.




回答3:


No, there isn't, because icon is determined by Java. Only way to do so (at least for Windows) is to use wrapper like launch4j and then set icon path. If you already have wrapped exe with no or wrong icon, you can use Recource Hacker and then follow turtorials on how to change icon. Otherwise, you can't change .jar's icon




回答4:


A possibility on mac is to use this line:

com.apple.eawt.Application.getApplication().setDockIconImage( new ImageIcon(getClass().getResource( "resources/appIcon.png" )).getImage());

It set your icon for the dock. I can't test it for now, i'm not working on a Mac but try it and get me up do date.




回答5:


As known, it is not possible to change .jar icon cause if you want to do it you should change all the .jar files in your operating system. Anyhow, a solution is possible. You can create a shortcut for the .jar and then you can change it: Right button >> Properties >> Change Icon.

p.s. The icon file should be a .ico, so you can use many site for conversion in .ico extension if your image has got another one.

Alternative 1: You can use also Launch4j, it's most simple way to generate application executable file.



来源:https://stackoverflow.com/questions/9590885/how-to-change-executable-jar-file-icon

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!