Loading image from jars from other jars etc

Discussion in 'Java' started by JavaEnquirer, Feb 22, 2006.

  1. JavaEnquirer

    JavaEnquirer Guest

    I have no problems loading an image from a jar using a class which
    shares that jar. However, if I have a utility jar which contains a
    ImageLoader utility class and use this class from my main application
    jar which contains the images, I get a null pointer exception on
    createImage.
    ( I'm using the utility class's class loader and calling the get
    resource method. ) I don't get a problem running my application
    jar-less in Eclipse.

    When I got this error I assumed that by default you can only load a
    resource from the same jar. So, I put the images into the utility jar
    too, but to no avail - the same error.

    Anyone got any pointers? Is there a way of loading resources from other
    jars as I'm trying to do?

    many thanks in advance.
    JavaEnquirer, Feb 22, 2006
    #1
    1. Advertising

  2. JavaEnquirer

    JavaEnquirer Guest

    I've just tried passing the class loader of the application ( whose jar
    contains the images ) to the ImageLoader class in the utility jar for
    it to use. This doesn't seem to work either. Is there any mileage in
    looking at the URLClassLoader class?
    JavaEnquirer, Feb 22, 2006
    #2
    1. Advertising

  3. JavaEnquirer

    JavaEnquirer Guest

    I've come across a suggestion that I ensure that my application.jar is
    included in the class path of my utility.jar. This way, the ImageLoader
    in utility.jar can load images from application.jar as requested by
    application.jar. I'd like to avoid this as utility jars shouldn't be
    coupled to code that may call them.
    JavaEnquirer, Feb 22, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ike
    Replies:
    6
    Views:
    1,054
    Andrew Thompson
    Sep 24, 2004
  2. Replies:
    5
    Views:
    9,029
  3. Kevin Walzer

    Re: PIL (etc etc etc) on OS X

    Kevin Walzer, Aug 1, 2008, in forum: Python
    Replies:
    4
    Views:
    390
    Fredrik Lundh
    Aug 13, 2008
  4. Ulf Meinhardt
    Replies:
    2
    Views:
    1,401
  5. edfialk
    Replies:
    0
    Views:
    187
    edfialk
    May 10, 2007
Loading...

Share This Page