This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Include icon image in JAR file and JAR icons Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Include icon image in JAR file and JAR icons" Watch "Include icon image in JAR file and JAR icons" New topic
Author

Include icon image in JAR file and JAR icons

Colin McTaggart
Ranch Hand

Joined: Feb 01, 2011
Posts: 46
Hi all,
I am developing a small desktop porgram and was wondering if it were possible to include the .ico file I use for my icon image and the .png file I use for my shortcut icon inside the JAR file. I was also wondering if it is possible to change the icon of my JAR file so it uses the .png icon instaid of the default JAVA one, any help would be much appreciated . I use Netbeans IDE to build my JAR file, this is relevant as I am a newbie and I don't know how to make a JAR file except by building in Netbeans :S.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38075
    
  22
If you're not used to building jars, this Java™ Tutorials pages (and adjacent pages) may help
You can certainly include image files in the .jar. Don't know about changing the desktop icon, however.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

In Windows you can only change the icon of an executable program. However a JAR file is not an executable any more than an Excel spreadsheet is. (It's java.exe which is the executable and it uses the jar as data, just as the spreadsheet is data used by the Excel.exe executable.)
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

Paul Clapham wrote:(It's javaw.exe which is the executable and it uses the jar as data, just as the spreadsheet is data used by the Excel.exe executable.)

There, I fixed it for you.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Colin McTaggart
Ranch Hand

Joined: Feb 01, 2011
Posts: 46
Sorry for the gap, I had to put this project on hold for a couple of weeks as my car was written off :S. What I do in windows just now is I have the .ico file in the install directory of my app then I manually make a windows shortcut and change the icon to my .ico. I also have a .png there that I use as my icon image. I plan on writing some code to automatically create this shortcut for me. Is it possible to store one or both of these files in the .JAR file?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Include icon image in JAR file and JAR icons
 
Similar Threads
How to get image (icon) from a JButton
application images for palm devices
Update an image file
Why did it have to be PNG
Problems loading images from application JAR