Results 1 to 2 of 2

Thread: [SOLVED] Quick question about exporting Jar files from eclipse, images not showing

  1. #1
    Join Date
    Jan 2006
    Location
    London, England
    Beans
    109
    Distro
    Hardy Heron (Ubuntu Development)

    Unhappy [SOLVED] Quick question about exporting Jar files from eclipse, images not showing

    Hi guys

    Im trying to export a Jar file from eclipse, and I'm having exactly the same problem i had last time i tried to do it (about a year ago!). I managed to fix it back then, but i can't for the life of me remember how!
    Basically, when i create a jar file using the export wizard in eclipse, none of my images show up, even though they are in the Jar file. Is it something to do with the classpath? the images are located in /img/ of the root of the jar.

    TIA

    James

  2. #2
    Join Date
    Jan 2006
    Location
    London, England
    Beans
    109
    Distro
    Hardy Heron (Ubuntu Development)

    Re: Quick question about exporting Jar files from eclipse, images not showing

    Don't worry, worked it out!
    for anyone with the same problem, make sure you're calling your images using this method:
    Code:
            // create a URL to get the image
            java.net.URL imgURL = getClass().getResource("/img/theimageyouwant.png");
    
             // insert the URL, rather than the address
    	private Image titleImg = Toolkit.getDefaultToolkit().getImage(imgURL);

Bookmarks

Posting Permissions

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