Cannot load ImageIcon image files from JAR file
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Cannot load ImageIcon image files from JAR file

  1. #1
    Join Date
    Jul 2017
    Posts
    1

    Cannot load ImageIcon image files from JAR file

    I can not load the images for my card game. My card class extends ImageIcon and I specify the path of the card image in the super method. When I compile and run it in TextPad it works, but when I export it into a JAR file I get null pointer exception.

    My code is like this:

    Code:
    super(Card.class.getResource("images/" + imagePath));
    I have tried with:

    Code:
    super("images/" + imagePath);
    
    super(Card.class.getClassLoader().getResource("images/" + imagePath));
    This is a screenshot from the decompiler of the jar file:

    http://i.imgur.com/6pMeLlN.jpg

    Any advice?

  2. #2
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,733

    Re: Cannot load ImageIcon image files from JAR file

    Norm

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This a Codeguru.com survey!


On-Demand Webinars (sponsored)