Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By Norm

Thread: Some "special gif file" couldn't load from my jar file

  1. #1
    Zamioculcas is offline Member
    Join Date
    Mar 2011
    Rep Power

    Default Some "special gif file" couldn't load from my jar file

    Hi Guys,
    I continue my GUI application, which contains more images. (antecedent:
    After running my application I packaged it to a jar file. Here is my output on the console:
    jar -cvf TestJar.jar TestJar.class images
    added manifest
    adding: TestJar.class(in = 1248) (out= 777)(deflated 37%)
    adding: images/(in = 0) (out= 0)(stored 0%)
    adding: images/bell.gif(in = 592) (out= 478)(deflated 19%)
    adding: images/drum.gif(in = 617) (out= 511)(deflated 17%)
    adding: images/Pluto3.gif(in = 2159) (out= 2122)(deflated 1%)
    adding: images/reindeer.gif(in = 600) (out= 587)(deflated 2%)
    adding: images/santa-hat.gif(in = 597) (out= 500)(deflated 16%)
    adding: images/skate.gif(in = 359) (out= 349)(deflated 2%)
    After that I put the main class info into the manifest.

    And now I noticed, I have some special image files which couldn't load from the jar file.
    For example pluto3.gif, I enclosed it with my code. What could be the difference between that file and the others ?
    I think the file size wouldn't be cause of my problem.
    Maybe It has got a special inner structure which differs from the others ? Or it would be a performance problem, and my computer is not too fast?

    I enclosed my all image files, they are placed in the images subdirectory which is on the same level with the class file.

    Any idea would be greatly appreciated!

    Here is my code:

    Java Code:
    import javax.swing.*;
    import java.awt.Graphics;
    import java.awt.image.BufferedImage;
    import javax.imageio.ImageIO;
    public class TestJar extends JPanel{
    public void paintComponent(Graphics g)
    		BufferedImage image;
                                  // I comment the images which works fine
                            image ="/images/bell.gif"));
    			image ="/images/drum.gif"));
    			image ="/images/reindeer.gif"));
    			image ="/images/skate.gif"));
                            //this file doesn't want to load 
    			image ="/images/pluto3.gif"));
    		catch( ioe)
    public static void main(String[] args)
    	TestJar tj = new TestJar();
    	JFrame frame = new JFrame("Merry Christmas...");
    Attached Thumbnails Attached Thumbnails Some "special gif file" couldn't load from my jar file-bell.gif   Some "special gif file" couldn't load from my jar file-drum.gif   Some "special gif file" couldn't load from my jar file-pluto3.gif   Some "special gif file" couldn't load from my jar file-reindeer.gif   Some "special gif file" couldn't load from my jar file-skate.gif  

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power

    Default Re: Some "special gif file" couldn't load from my jar file

    What is different from the 4 statements that work and the one that does not work?
    Are you sure the image is in the jar file in the correct location. It should be in the same folder as the images that you can read.

    Have you spelled the name correctly?
    pbrockway2 likes this.

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power

    Default Re: Some "special gif file" couldn't load from my jar file

    Mind the capitalization of your resource names.

    kind regards,

    Build a wall around Donald Trump; I'll pay for it.

Similar Threads

  1. Couldn't load my image from the jar file
    By Zamioculcas in forum New To Java
    Replies: 8
    Last Post: 12-30-2011, 04:54 PM
  2. Replies: 6
    Last Post: 04-05-2011, 11:33 AM
  3. Replies: 6
    Last Post: 02-10-2011, 10:55 AM
  4. Replies: 4
    Last Post: 11-06-2010, 12:50 AM
  5. Replies: 1
    Last Post: 10-20-2008, 08:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts