Image Jars

Discussion in 'Java' started by FET, Jul 24, 2003.

  1. FET

    FET Guest

    Hi all,
    I have an application that has lots of classes. These are clubbed into
    4 packages. These classes use images as well which are currently in a
    directory. Everytime, I have to copy the images to install the
    application. I would like these images to be in a jar file, maybe a
    separate jar coz the use of these images is spread out across 4
    packages so I cant possibly put all the images in all the 4 jars.
    Please advise as I am unable to access the images from another jar
    from the class that requires these images which is in a different jar.

    Thank you in advance.
    Regards.
    FET, Jul 24, 2003
    #1
    1. Advertising

  2. (FET), Wed, 23 Jul 2003 20:55:26 -0700:

    > Hi all,
    > I have an application that has lots of classes. These are clubbed into
    > 4 packages. These classes use images as well which are currently in a
    > directory. Everytime, I have to copy the images to install the
    > application.


    > I would like these images to be in a jar file, maybe a
    > separate jar coz the use of these images is spread out across 4
    > packages so I cant possibly put all the images in all the 4 jars.
    > Please advise as I am unable to access the images from another jar
    > from the class that requires these images which is in a different jar.


    How are you trying to access the images currently? It should be no
    problem, as long as all the JAR files have been specified on the
    class path, you can access the images, simply by calling:

    URL url = getClass().getResource("/directoryInAJar/image.gif");

    <a
    href="http://www.javalobby.com/threadMode_printfriendly.jsp?forum=16&thread=7992">
    There are examples about this.
    </a>

    <a
    href="http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Class.html#getResource(java.lang.String)">
    Or consult the API documentation.
    <a/>

    What getClass().getResource(String) actually does is, call the class
    loader to find out whether any given resource can be found in the search
    path / class path of the current class loader.

    Greets
    Bhun.
    path







    ---
    I've got Yamara.NET++ (the Ogrek edition).
    dhek bhun kho, Jul 24, 2003
    #2
    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. Wendy S

    Re: classpath & too many jars

    Wendy S, Jul 22, 2003, in forum: Java
    Replies:
    1
    Views:
    467
    Wendy S
    Jul 22, 2003
  2. Ike
    Replies:
    6
    Views:
    1,048
    Andrew Thompson
    Sep 24, 2004
  3. Replies:
    5
    Views:
    9,016
  4. JavaEnquirer
    Replies:
    2
    Views:
    510
    JavaEnquirer
    Feb 22, 2006
  5. Ulf Meinhardt
    Replies:
    2
    Views:
    1,399
Loading...

Share This Page