• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

listing contents of jar file once its loaded into the local system

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a Config.jar file on the server, which contains xml files inside some subdirectories. When my applet gets loaded the config.jar file loads into my local machine and I can access the files from it using ClassName.class.getResourceAsStream(config\filename.xml);

Now the problem I have to list the entire contents of the config.jar file once I get it onto the local system. I tried something very lame like ClassName.class.getResourceAsStream(config), where config is the name of the directory, so that I could get the directory and once I have that, I could just list the contents of the directory, it didn�t work.

Is there a way of listing the contents once the jar file is loaded into JVM?

Thank you,
anirudh
 
Rancher
Posts: 5008
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes.
Look at the ZipFile class.
 
Norm Radder
Rancher
Posts: 5008
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That depends what "loaded on the local system" means and what permissions the applet has.
If the jar is being controlled by the plugin, it's not really available outside of the JVM. I don't think there are any API that would be able to look at it. It doesn't really exist as a file for the running program. Its used by the JVM to locate resources such as classes.
If the jar file is on a local drive as a file, then ZipFile (with permission) can see it.
 
anirudh takkallapally
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply Norm, i am using URLClassLoader to load the config.jar file into JVM, dont have the jar file on the local file system. The only solution i could come up with is to have a file called directorylisting.xml in the jar file, this directorylisting.xml would contain the list of files and the directory structure inside the jar file and when i need to know the list of files i would just access the directorylisting.xml inside the jar file.

Please do let me know if you have an alternate solution.

thank you,
anirudh
 
Norm Radder
Rancher
Posts: 5008
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That sounds like a good solution.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic