File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes How to view jar files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "How to view jar files" Watch "How to view jar files" New topic
Author

How to view jar files

Geoff Garcia
Greenhorn

Joined: Jul 10, 2003
Posts: 22
Aright, I'm pretty much a java newbie.
I understand the basics of the language but have never done real work in it.
Currently I find myself on a project where I'm going to have to do some java development.
I'm at a stage now where I'd like to know whats in all of the jar files utilized by a 3rd party software company that I am interfacing a portal gadget into.
there are a ton of jar files, I've isolated the one I want to view the contents of, but how do I open the darn thing? I've tried wordpad which obviously doesn't work.
Is there some commands I need to run to seperate the .jar file and then be able to view the contents?
Thanks for any help on this simple/novice problem.
Geoff
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
The JDK contains a utility called "jar". You can create, update, extract, and view .jar files using the "jar" utility.
Here are some useful commands:

Hope I didn't post too many typos


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
damien malone
Ranch Hand

Joined: May 06, 2003
Posts: 35
you can open up, add and remove files from jar files by using winzip if you want, might be of some help to you
Ashik Uzzaman
Ranch Hand

Joined: Jul 05, 2001
Posts: 2370

I strongly recommend WinRar which is very useful for exploring several kinds of compressed files including ZIP, WAR, TAR etc. I am sure you'ld delighted to get it.


Ashik Uzzaman
Senior Member of Technical Staff, Salesforce.com, San Francisco, CA, USA.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Geoff, if you decide to use WinZip/WinRAR/whatever tools for handling your .jar/.war/.ear files, do remember that a valid .jar file must contain the META-INF/MANIFEST.MF file, which is added by default by the jar utility. With WinZip and others, you must create and add the manifest file yourself (it's not difficult, though).
Arvind Varma
Ranch Hand

Joined: Dec 24, 2002
Posts: 48
The commands lasse gave are right..but u can add option 'v' to get a verbose version ..

// Gives the table of contents in verbose fashion
jar -tvf
similarly,
//Extracts the files by displaying the information of every file that is being extracted.
jar -xvf
Geoff Garcia
Greenhorn

Joined: Jul 10, 2003
Posts: 22
well thanks for the help! I just used the simple winzip tool and got a peek at all the class files in the jars...
I dont know what I was thinking though, looking at .class files is useless to me! I'm trying to figure out why a .jsp call I'm making is failing and thought that by looking at the code of the method I might get a better handle on things.
Any suggestions?
Is there a way to view a .java file from a .class file?
Vinod John
Ranch Hand

Joined: Jun 23, 2003
Posts: 162
Originally posted by Geoff Garcia:

Is there a way to view a .java file from a .class file?

You can actually unjar/unzip the jar file and use a decompiler like JAD to decompile the class file.
http://www.geocities.com/zz_xu/jad.html
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to view jar files