Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Reading icon using ImageIO.Read  RSS feed

 
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Currently, I put my icon for my Frame in my "src" folder, where src is inside of the application folder.
I am using Netbeans.

When this runs inside netbeans, it is fine. But when it is compiled as a jar, I've got null exception thrown by this method as it is running.
I've put the same .png file inside the dist folder. Where am I supposed to put the JFrame folder's icon?
Thanks
Jack
 
Sheriff
Posts: 23706
50
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should go in the root folder in the jar file. That's what it means to use an absolute URL, as you did in that case. Your Netbeans "src" and "dist" folders have nothing to do with anything once you generate the jar, so just forget about them. If they are in the jar, then you have done something wrong while creating it.

And by the way it's less confusing to just use an ordinary absolute URL, like this:
 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul,
I am still experiencing some difficulties, I use the directory as you informed me.
I put the bokss.png file in the same folder with the manifest.mf and build.xml.
I even can't execute the application in netbeans.
Thanks
Jack
 
Sheriff
Posts: 21458
96
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually Paul, the original resource was relative to the class file itself (the ./ works in resources just like in file systems). And that's where the icon should be - inside the JAR file. Don't assume it automatically gets packed. Check if it is, and if it isn't make sure it is.

The location inside the JAR file also matters. If the resource is relative (like ./bokss.png) then the icon must be located relative to the class file. If it's absolute (like /bokss.png) then it must be located to the root of the JAR file. Unlike the manifest file which must be placed inside the META-INF folder inside the JAR file.
 
Paul Clapham
Sheriff
Posts: 23706
50
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Rob Spoor wrote:Actually Paul, the original resource was relative to the class file itself (the ./ works in resources just like in file systems).



That's why I used the word "confusing" in my response. When "./abc" is the same thing as "abc" then you should not use the more complicated form.
 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:

Rob Spoor wrote:Actually Paul, the original resource was relative to the class file itself (the ./ works in resources just like in file systems).



That's why I used the word "confusing" in my response. When "./abc" is the same thing as "abc" then you should not use the more complicated form.



2 points I would like to raise
I can do one of the options either
1) add the bokss.png file to the jar file
2) modify the manifest.mf



I prefer the second method to the first. How do I modify this file to include the png file?
Thanks
Jack
 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jack Luk wrote:

Paul Clapham wrote:

Rob Spoor wrote:Actually Paul, the original resource was relative to the class file itself (the ./ works in resources just like in file systems).



That's why I used the word "confusing" in my response. When "./abc" is the same thing as "abc" then you should not use the more complicated form.



2 points I would like to raise
I can do one of the options either
1) add the bokss.png file to the jar file
2) modify the manifest.mf



I prefer the second method to the first. How do I modify this file to include the png file?
Thanks
Jack



I've solved it. Sorry, but I've lost the link that I originally wanted to share with you. Just google something like "manifest.mf resource png"
But I can't get to it.
Thanks
Jack
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!