This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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?
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.
Joined: Sep 04, 2003
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.