Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #21498

Re: resources from JAR files

From Roedy Green <see_website@mindprod.com.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: resources from JAR files
Date 2013-01-17 15:07 -0800
Organization Canadian Mind Products
Message-ID <vo0hf8tcjb66jan5a3dsfj7s769nbstd36@4ax.com> (permalink)
References <f7a28e33-5e29-45fd-8c15-762e8ee4cdc2@googlegroups.com>

Show all headers | View raw


On Thu, 17 Jan 2013 08:30:23 -0800 (PST), bob smith
<bob@coolfone.comze.com> wrote, quoted or indirectly quoted someone
who said :

>I have some code that reads an image from its JAR file like so:
>
>img = ImageIO.read(frame.getClass().getResource("whatever.jpg"));
>
>I basically just picked the "frame" object at random to call the getClass() method on it.
>
>Is there a way to do this without picking an arbitrary object?  It seems so wrong.

It is really just looking for a package name to find the resource. You
can name the main class explicitly  MyProg.class or this.getClass()
There is no Package class, so they use Class. You want something in
YOUR package.

see http://mindprod.com/jgloss/resource.html
-- 
Roedy Green Canadian Mind Products http://mindprod.com
The first 90% of the code accounts for the first 90% of the development time.
The remaining 10% of the code accounts for the other 90% of the development 
time. 
~ Tom Cargill  Ninety-ninety Law 

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

resources from JAR files bob smith <bob@coolfone.comze.com> - 2013-01-17 08:30 -0800
  Re: resources from JAR files markspace <markspace@nospam.nospam> - 2013-01-17 08:54 -0800
  Re: resources from JAR files Roedy Green <see_website@mindprod.com.invalid> - 2013-01-17 15:07 -0800
    Re: resources from JAR files Lew <lewbloch@gmail.com> - 2013-01-17 15:16 -0800
      Re: resources from JAR files Roedy Green <see_website@mindprod.com.invalid> - 2013-01-17 16:36 -0800
        Re: resources from JAR files Arne Vajhøj <arne@vajhoej.dk> - 2013-01-17 19:44 -0500
  Re: resources from JAR files Arne Vajhøj <arne@vajhoej.dk> - 2013-01-17 18:13 -0500
    Re: resources from JAR files BGB <cr88192@hotmail.com> - 2013-01-25 15:08 -0600
      Re: resources from JAR files Arne Vajhøj <arne@vajhoej.dk> - 2013-01-25 20:57 -0500
        Re: resources from JAR files Lew <lewbloch@gmail.com> - 2013-01-25 22:32 -0800

csiph-web