5 Replies Latest reply: Mar 9, 2011 5:09 PM by 843990 RSS

    Accessing Resources through getResource() Not Working

      I have created a JAR file using Eclipse. The JAR includes my class files, and few JPG images.
      I'm trying to access those JPG images through one of the classes in the JAR.

      All classes and images are found on the top level of the JAR (I mean, not inside a folder).

      I've read that accessing resources in this manner is done using this.getClass().getResource(String path).

      I wasn't sure what the path should be like, so I've tried the three possible options I had in mind:

      -Sending the image name as it is (for example, "next.jpg")
      -Sending the name, with a slash before it ("/next.jpg")
      -Sending the name with two backslashes before it.

      I'm checking after each of these calls whether url is null, and it is always null. What should I be doing differently?

      I appreciate your help.