Results 1 to 2 of 2
  1. #1
    JohnST is offline Member
    Join Date
    Dec 2009
    Posts
    20
    Rep Power
    0

    Default trouble with images .jpg's in linux

    Im having trouble getting Image .jpg's to show up in an executable JAR in linux. When I run the project in DrJava images are there. When I run a compiled JAR in windows it works fine, but the compiled JAR in linux has images missing. I have other images for buttons that work fine. The albumart[i] contains a folder with an image in it like
    60/609830cb-a007-4c46-8039-5ad1d7a0139f
    I printed the complete URL's they all look fine but none of the album images show up not even the default_m.jpg
    Here is the printed URL that I get:
    images/album/60/609830cb-a007-4c46-8039-5ad1d7a0139f_m.jpg
    All the paths are right I placed images/album/60/etc.....etc in the compiled JAR

    Anyone know what could be wrong?
    Thanks,
    John

    Java Code:
     String resourcePath = "images/album/"+albumart[i]+"_m.jpg";
            
            URL flagUrl = getClass().getResource(resourcePath);
            boolean exists = flagUrl != null;
            
            
            System.out.println(resourcePath);
            
            if (!exists){
            resourcePath = "images/album/default_m.jpg";
             }
    
            ImageIcon icon = new ImageIcon("images/album/"+albumart[i]+"_m.jpg");

  2. #2
    JohnST is offline Member
    Join Date
    Dec 2009
    Posts
    20
    Rep Power
    0

    Default

    Okay I got it working. I just had to look at the images that were working right.

    Java Code:
            String resourcePath = "images/album/"+albumart[i]+"_m.jpg";
            
            URL flagUrl = getClass().getResource(resourcePath);
            boolean exists = flagUrl != null;
            
            //System.out.println(resourcePath);
            
            if (!exists){
            
            resourcePath = "images/album/default_m.jpg";
            
             }
             ImageIcon icon = new ImageIcon(getClass().getResource(resourcePath));

Similar Threads

  1. Replies: 3
    Last Post: 11-11-2009, 03:19 AM
  2. runable . jar in linux
    By pellebye in forum Eclipse
    Replies: 11
    Last Post: 08-22-2009, 03:47 PM
  3. Where to get jdk1.5 for linux
    By ran_sushmi in forum Advanced Java
    Replies: 0
    Last Post: 07-20-2009, 02:46 PM
  4. Replies: 6
    Last Post: 04-08-2009, 04:05 AM
  5. Java On Linux
    By Natrix in forum New To Java
    Replies: 15
    Last Post: 04-08-2009, 12:31 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
  •