# Reading .jar files

**URL:** <https://www.ruby-forum.com/t/reading-jar-files/80576>\
**Category:** Ruby\
**Created:** [December 28, 2006, 7:53pm UTC](https://www.ruby-forum.com/t/reading-jar-files/80576 "2006-12-28T19:53:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![markcasio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9bcb4/32.png) [@markcasio](https://www.ruby-forum.com/u/markcasio)\
**Post date:** [December 28, 2006, 7:53pm UTC](https://www.ruby-forum.com/t/reading-jar-files/80576/1 "2006-12-28T19:53:23Z")

</div>

How can I read the entries in a Java .jar file from Ruby?

I tried the standard library Zlib, but that doesn’t work … I think  
because .jar files use the zip format instead of the gzip format.

I tried the rubyzip library at [http://rubyzip.sourceforge.net/](http://rubyzip.sourceforge.net/). For  
some reason that didn’t get to all the entries in the file, only  
“META-INF/” and “META-INF/MANIFEST.MF”.

---

<div class="post-metadata">

**Author:** ![markcasio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9bcb4/32.png) [@markcasio](https://www.ruby-forum.com/u/markcasio)\
**Post date:** [December 30, 2006, 1:15pm UTC](https://www.ruby-forum.com/t/reading-jar-files/80576/2 "2006-12-30T13:15:45Z")

</div>

Mark V. wrote:

> How can I read the entries in a Java .jar file from Ruby?
> 
> I tried the standard library Zlib, but that doesn’t work … I think  
> because .jar files use the zip format instead of the gzip format.
> 
> I tried the rubyzip library at [http://rubyzip.sourceforge.net/](http://rubyzip.sourceforge.net/). For some  
> reason that didn’t get to all the entries in the file, only “META-INF/”  
> and “META-INF/MANIFEST.MF”.

rubyzip should be able to read the jar file. Can you send me a .jar file  
that is causing you problems.

Best regards,

Thomas Sondergaard

---

<div class="post-metadata">

**Author:** ![markcasio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e9bcb4/32.png) [@markcasio](https://www.ruby-forum.com/u/markcasio)\
**Post date:** [December 28, 2006, 11:45pm UTC](https://www.ruby-forum.com/t/reading-jar-files/80576/3 "2006-12-28T23:45:59Z")

</div>

On 12/28/06, Mark V. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> How can I read the entries in a Java .jar file from Ruby?
> 
> I tried the standard library Zlib, but that doesn’t work … I think  
> because .jar files use the zip format instead of the gzip format.
> 
> I tried the rubyzip library at [http://rubyzip.sourceforge.net/](http://rubyzip.sourceforge.net/). For  
> some reason that didn’t get to all the entries in the file, only  
> “META-INF/” and “META-INF/MANIFEST.MF”.

Perhaps you should simply call the jar program, or unzip, instead of  
trying to read the file directly.

Mike
