• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Icons and Images question

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hope I'm in the right section,

Just want to know why my Frames and menuItem imageicons do not work when I put it in a jar file? Running the app outside of the jar, icons etc works fine.
Any help would be appreciated!
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://download.oracle.com/javase/tutorial/uiswing/components/icon.html#getresource

If that's not it, post a SSCCE that demonstrates your problem.
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As another step I would also check that the image file is actually within the Jar.

I remember once having the same issue as yourself and I realised I forgot to include the file extension within my ant build file.
 
Werner Fletcher
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey guys, thanks for the info, really appreciate it. One issue I have now... here is the code:



This works fine when I run it via a batch file, but when everything is in a .jar file, the program does not start up at all... I verified that all the images and classes are in the right place.
 
Darryl Burke
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://download.oracle.com/javase/tutorial/deployment/jar/manifestindex.html

Again, if that's not it post a SSCCE. Also post the internal structure of the associated jar file.

edit

when everything is in a .jar file, the program does not start up at all


You need to tell us exactly how you attempted to run the program.
 
Werner Fletcher
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had a look at the link you gave me. I am sure that I did it right. The jar runs fine when I take the

code out. As I said, the app runs fine with the above code when I run it via command line, but not in jar. I have attached images of the jar contents aswell as the app directory and contents of the manifest file. The code I use to compile my jar file is: jar cvfm NetChatClient.jar manifest.txt *.class img/*.*
client.PNG
[Thumbnail for client.PNG]
jar.PNG
[Thumbnail for jar.PNG]
 
Werner Fletcher
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OH MY WORD guys, I found the problem. I'm sorry for this whole discussion, I feel like such an idiot now. The problem was that I used dir//file instead of dir/file in my URLs. Sorry again... Please close this thread, thanks.
reply
    Bookmark Topic Watch Topic
  • New Topic