1 Reply Latest reply on Mar 30, 2010 5:18 PM by 843804

    Problem in loading images.

      I am doing a project. I am creating a jar file which i can execute anywhere. I have some 30 class files in my project.
      i am creating jar file by this command
      jar cfm IBC.jar *
      i have not specified manifest file and then after i am modifying manifest file as
      Main-Class: Splashscreen
      where spashscreen is my main class.

      i have also added image files in my project.
      and jar file contains images.
      i have created the project using netbeans.
      when i build it creates a jar file also in dist directory.
      But when i try executing the file which i created manually then it gets executed but i cannot view the images on my forms.
      also the class files and image files are in src directory. When i place jar file in src directory and execute it shows images on form but when i change the directory it does not. What can be the problem. Same problem is with netbeans generated file also. Please help me!
        • 1. Re: Problem in loading images.
          Hello there,
          To load images to Jars I recommend to you that you follow these methods
          JLabel label = new JLabel(); 
          ClassLoader cldr = this.getClass().getClassLoader();
          java.net.URL imgUrl = cldr.getResource(" -- img dir -- ");
          ImageIcon img = new ImageIcon(imUrl); 
          In this case the Jars files would make sure that it loads this images.