| Author |
extract jar file programatically
|
Cloey Tan
Ranch Hand
Joined: Feb 03, 2009
Posts: 60
|
|
Dear all,
Using java, is there a way to extract jar file such that i can look for certain package, and list out out all the files belong to that particular package? Hope for some guidelines and helpful resouces.
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24061
|
|
A jar file is actually just a zip file. You can use the java.util.jar package to look through a jar file and find whatever entries you want; for example, this prints out the name of each entry in a jar file:
|
[Jess in Action][AskingGoodQuestions]
|
 |
Cloey Tan
Ranch Hand
Joined: Feb 03, 2009
Posts: 60
|
|
Thanks it works. but i have another few questions to ask here
I create a project and build it with maven using the following simple example:
http://maven.apache.org/guides/getti...e-minutes.html
Then, i add a new file, called test.xml under the main root of the project, then use the above code to loop through the files, test.xml doesnt seem to get listed. And i found from this site http://www.cezwright.com/tools/java/jar_war_ear.htm, that jar doesnt include xml file, but then pom.xml get listed, but not test.xml which has been newly added.
Besides, if i were to package everything in war, how to do the settings in pom.xml?
|
 |
Martijn Verburg
author
Bartender
Joined: Jun 24, 2003
Posts: 3268
|
|
Hi Cloey,
Can you please re-post your last question in our Ant, Maven and Build tools forum, you'll get better help there
|
Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
|
 |
 |
|
|
subject: extract jar file programatically
|
|
|