Reputation: 41
I developed a javafx application. I want to change the java default icon of .jar file. I tried this primaryStage.getIcons().add(icon);
but this only make change the left top corner icon when running the app not the external view image.
screenshot below: https://i.sstatic.net/GoShA.png I want to change this icon actually.
Upvotes: 3
Views: 635
Reputation: 36722
All Jar files have the same icon and it depends on the OS to show an icon on a file depending on the file type.
primaryStage.getIcons().add(icon);
The above line will only get executed when a JVM is created for the application, so it doesn't make sense to depend on this particular piece code to display an icon :)
If you want to change the file icon, you will have to wrap the executable jar file to create a new native executable file (which depends on the OS). For example - EXE for windows. This new file will contain the image file to be displayed and the jar to be executed.
You can try using Launch4j or JSmooth for creating a wrapper file.
Upvotes: 2