aspose file tools*
The moose likes Java in General and the fly likes Icons and Images question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Icons and Images question" Watch "Icons and Images question" New topic
Author

Icons and Images question

Werner Fletcher
Ranch Hand

Joined: Apr 19, 2011
Posts: 34
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

Joined: May 03, 2008
Posts: 4528
    
    5

http://download.oracle.com/javase/tutorial/uiswing/components/icon.html#getresource

If that's not it, post a SSCCE that demonstrates your problem.


luck, db
There are no new questions, but there may be new answers.
Joshua Barrett
Greenhorn

Joined: Sep 08, 2010
Posts: 27
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

Joined: Apr 19, 2011
Posts: 34
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

Joined: May 03, 2008
Posts: 4528
    
    5

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

Joined: Apr 19, 2011
Posts: 34
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/*.*


[Thumbnail for client.PNG]

[Thumbnail for jar.PNG]

Werner Fletcher
Ranch Hand

Joined: Apr 19, 2011
Posts: 34
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Icons and Images question