Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Icons and Images question

 
Werner Fletcher
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • 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!
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • 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.
 
Joshua Barrett
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • 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
  • 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: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic