aspose file tools
The moose likes Java in General and the fly likes How do I list the content of a file that is packed inside a jar file? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "How do I list the content of a file that is packed inside a jar file?" Watch "How do I list the content of a file that is packed inside a jar file?" New topic
Author

How do I list the content of a file that is packed inside a jar file?

Rogerio Kioshi
Ranch Hand

Joined: Apr 12, 2005
Posts: 659
Hi,

I'd like to know if there is a way to list the content of a file (an xml file, for instance) that is packed inside a jar file.

Is there an option in jar command line to do this?


SCEA 5 (part 1), SCBCD, SCWCD, SCJP, CLP, CLS
Kevin Workman
Ranch Hand

Joined: Sep 28, 2010
Posts: 151
Rogerio Kioshi wrote:Hi,

I'd like to know if there is a way to list the content of a file (an xml file, for instance) that is packed inside a jar file.

Is there an option in jar command line to do this?


This is the first result when I googled "jar view contents": http://java.sun.com/developer/Books/javaprogramming/JAR/basics/view.html

Is that what you mean?
Rogerio Kioshi
Ranch Hand

Joined: Apr 12, 2005
Posts: 659
Kevin Workman wrote:
Rogerio Kioshi wrote:Hi,

I'd like to know if there is a way to list the content of a file (an xml file, for instance) that is packed inside a jar file.

Is there an option in jar command line to do this?


This is the first result when I googled "jar view contents": http://java.sun.com/developer/Books/javaprogramming/JAR/basics/view.html

Is that what you mean?


Not exactly. I'll explain: I have a file called persistence.xml inside the folder META-INF. This folder is packed in a jar file. What I wanted to do is that, from a command line, I could see what is written in the persistence.xml file. It would be like doing a "cat pesristence.xml", without having to unzip the jar file. I hope it is clearest to understand, now...
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

No, but you could extract just that file. Or use any of the normal zip applications to open it in a file viewer.
Rogerio Kioshi
Ranch Hand

Joined: Apr 12, 2005
Posts: 659
David Newton wrote:No, but you could extract just that file. Or use any of the normal zip applications to open it in a file viewer.


That's the way I'm doing, but I wanted to avoid opening the jar file all the time.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

No real way around that--it's in a jar file. *Something* will have to open it, but it's invisible in most OSes with appropriate explorer plugins.
Ireneusz Kordal
Ranch Hand

Joined: Jun 21, 2008
Posts: 423
Jar is an ordinary ZIP archive, you can exctract/view files using ZIP tools.
Simple example - commands issued from the linux console:
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

That's kind of what we've been talking about.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: How do I list the content of a file that is packed inside a jar file?
 
Similar Threads
Executable jar Failed to load Main-Class manifest attribute
Files inside the Jar
view content of file in a jar file
readme.txt
opening a html file packed inside a jar