Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Java
Hello everybody!
 
I would like to first start by saying thanks to everyone who takes some time to view this thread and try to help.
 
I am building GUI in JAVA.
I wanted to change JAVA's default icon ( coffee cup ) into my own icon.
 
The problem i have is following:
 
I have managed to change icon successfully for main form, but when I go to dist folder, I have a .jar file that has icon of its own.
My client wants its own icon to be seen everywhere, they are not interested in one JAVA offers.
 
So my question is:
 
How can I change icon on .jar file from default into one of my own choice?
 
---------------------------------------------------
 
I use Netbeans IDE and have JAVA SE 7.
 
If any other information is required ( source code or something similar ), please ask for it, I will more than gladly supply it.
 
----------------------------------------------------
 
Again,thank you all!
Posted 30-Apr-13 15:16pm
Comments
ThePhantomUpvoter at 30-Apr-13 21:22pm
   
http://stackoverflow.com/questions/209812/how-do-i-change-the-default-application-icon-in-java
H.Brydon at 1-May-13 0:35am
   
Enter that as a solution and you'll get a +5 from me. :-)
Nenad Smiljkovic at 2-May-13 12:22pm
   
Actually,I have stumbled upon this solution myself! :))) Sadly,it does not change the icon of a .jar file. :((( Thank you for reply,anyway. :)

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Sorry to say but, you cannot change the icon displayed on the jar file directly. That's the icon displayed by your file browser/operating system for the file type.
 
You cannot do that unless:
1. You change the icon in the registry (for windows) or icon theme(for POSIX). But this will change the icon for all jars.
2. Use a shell hook. But it is Windows only and requires messy C++ coding.
 
These are not good practices. They just mess up things.
 

If your client wants to see the icon everywhere, then you can try these:
1. Add a shortcut to the desktop/app launcher with your icon.
 
2. If your deployment platform is windows
wrap your app in a launcher exe with your icon (ico file). Launch4j is a good option.
 
If platform is Linux, then add a .desktop file refering the icon and the icon (png file) to /usr/share/icons/hicolor/SIZE/apps/ where size must be 16,24,32,64 and 256
 
If mac,
Sorry, I don't know how to assign an app icon on that platform, a bit googling will do.
 
Good luck!
  Permalink  
v2
Comments
Nenad Smiljkovic at 2-May-13 12:18pm
   
Unfortunately,I must agree with you.
Everything you said is true,but I still hoped to find some way to
do it.
Thank you,and everybody else who tried...
Amitosh Swain at 3-May-13 3:21am
   
Depending upon the deployment platform, you can "wrap" it into an executable. That's a good idea and is used with programs like Netbeans, Eclipse and many others.
Nenad Smiljkovic at 4-May-13 18:04pm
   
I like this solution.
Can you provide some links to tutorials or recommend some books?
Thank you.
Amitosh Swain at 4-May-13 20:43pm
   
For learning JAVA??
Nenad Smiljkovic at 5-May-13 17:29pm
   
No! hahaha :)))
For wraping it up in an .exe.
Amitosh Swain at 6-May-13 7:44am
   
It's straight forward. It's got a nice GUI with a wizard interface. Download from the site, run the executable, select your exe, configure some options like JRE version, JVM start-up commands, splash screen etc. Click save, your executable will be created. It's very easy and the site has even got documentation for it.
Nenad Smiljkovic at 6-May-13 10:42am
   
Thank you!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 350
1 Jochen Arndt 150
2 Richard MacCutchan 135
3 PIEBALDconsult 110
4 Sergey Alexandrovich Kryukov 104
0 OriginalGriff 6,055
1 DamithSL 4,621
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,500
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 2 May 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100