• Post Reply Bookmark Topic Watch Topic
  • New Topic

Jar File Resources  RSS feed

 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My application is a JAR file and I am needing to get a group of resources all at one time with specifically specifying the file names. I know how to get a single resources, for example. getClass().getClassLoader().getResource("") but I have a directory full of images and I need to get all the image names.

So basically, if I were to do this outside of a JAR file I would do something like:



And that would get all my file names in the File[] array. Is there an easy method of doing the same thing from within a JAR? You can't get File objects when your application is running from a JAR because it will look outside the JAR file for those resources.

Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66304
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Although I've never used it, perhaps the classes in the java.util.jar package would help you inspect the contents of the jar file.
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Gregg,
there is a piece of code over at the Java Almanac that shows you how to list the entries of your JAR file. With that, you can get your images back.
 
Fisher Daniel
Ranch Hand
Posts: 582
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I dont know if it is proper for your case.
I think you can use classes in package java.util.zip.* to get name and the content of your JAR file.

Correct me if I am wrong

thanks
daniel
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi hope this help's u ...


[ November 07, 2004: Message edited by: srini vasan ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!