Page 2 of 2 FirstFirst 12
Results 21 to 23 of 23
  1. #21
    JayF is offline Member
    Join Date
    Apr 2012
    Posts
    13
    Rep Power
    0

    Default Re: Java Images via JAR

    Not the same line, but a similar line
    Java Code:
    icon = new ImageIcon(getClass().getResource("/images/"+name+".png"));
    The argument given to the ImageIcon equates (in the IDE) to ../src/images/majors/image.png

  2. #22
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default Re: Java Images via JAR

    So...does the image you are trying to access on that line exist within the jar? According to the exception there is a discrepancy between that path, and what exists within your jar.

  3. #23
    JayF is offline Member
    Join Date
    Apr 2012
    Posts
    13
    Rep Power
    0

    Default Re: Java Images via JAR

    The error wasn't where I thought it was, it was with different icons.

    The bg.png displays correctly, but the other images in the same folder don't.


    EDIT: I've got it working correctly now. The issue was that the path is case sensitive - stupid error. Thank you for your help.
    Last edited by JayF; 04-05-2012 at 11:34 PM.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 0
    Last Post: 12-16-2010, 05:14 PM
  2. Replies: 4
    Last Post: 12-16-2010, 04:32 PM
  3. Java Applets and Images
    By Danioson in forum Java Applets
    Replies: 7
    Last Post: 08-02-2010, 12:30 PM
  4. Replies: 7
    Last Post: 07-22-2008, 05:54 PM
  5. Help using images in Java
    By toby in forum Advanced Java
    Replies: 1
    Last Post: 08-07-2007, 05:54 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
  •