wood burning stoves 2.0*
The moose likes Linux / UNIX and the fly likes how to look for jar file content in linux? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "how to look for jar file content in linux?" Watch "how to look for jar file content in linux?" New topic
Author

how to look for jar file content in linux?

Amandeep Singh
Ranch Hand

Joined: Jul 17, 2008
Posts: 844
Like in windows, if we open the jar file through winzip, we can see its contents.
Similarly without unzipping the jar file (means not creating a clutter of file by unzipping), we can see its contents.

Is it possible?


SCJP 1.4, SCWCD 5, SCBCD 5, OCPJWSD 5,SCEA-1, Started Assignment Part 2
My blog- http://rkydesigns.blogspot.com
Philip Thamaravelil
Ranch Hand

Joined: Feb 09, 2006
Posts: 99
You can do this several ways in linux..

You can use:

#unzip -t file.jar | grep -i 'what your looking for'

which will give you a listing of it's contents including directory structure without actually unzipping it.


Alternatively, you can use
# find . -name file.jar | xargs grep -i 'what your looking for'

which will display the jar file, and a response if it was found in the jar.

cheers

Philip
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14269
    
  21

Just use the JAR tool that's included with the JDK (see documentation).

To list the files and directories inside a JAR:

jar tvf filename.jar


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Amandeep Singh
Ranch Hand

Joined: Jul 17, 2008
Posts: 844
Thanks for the reply. Actually i have a jar file of java classes.
The commands mentioned by you did not worked. it just says Binary matches jar file.
It won't let me to peek in the jar file.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

Amandeep Singh wrote:The commands mentioned by you did not worked. it just says Binary matches jar file.


http://faq.javaranch.com/java/ItDoesntWorkIsUseless
Please post the exact command entered and the response (copy and past it from your terminal window).


JBoss In Action
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to look for jar file content in linux?