[java] Viewing contents of a .jar file

What would be the easiest way to view classes, methods, properties, etc. inside a jar file? I'm looking for something equivalent to the very useful Lutz Roeder .NET Reflector - for Java

This question is related to java jar viewer

The answer is


You can open them with most decompression utilities these days, then just get something like DJ Java Decompiler if you want to view the source.


Use WinRar. It will open the folder structure for you in intact manner. Also allows in-archive editing, while preserving paths.

Afterall, a JAR file is a ZIP archive only.


You could try JarSpy. There is an IDEA plugin version of it that I use.


Jad is klunky and no longer maintained. I've switched to "Java Decompiler", which has a slick UI and support for new language features.

Every decompiler I've used, though, runs into code it doesn't successfully decompile. For those, it helps to understand the disassembled Java byte code produced by the standard JDK tool, javap.


What I use personally is JD-GUI. It is a free 'decompiler', as it allows you to see the source code, classes, and objects in the classes, as well as see the file structure in a tree menu to the left. However, it does not allow you to modify the classes directly.

JD-GUI's website: http://jd.benow.ca/


jar -tvf file_name.jar

above will only print names of the files.

To view the content of files, you can extract the files in a folder by:

jar -xvf file_name.jar

this will unzip jar file & put the content in same directory where you are running this.

Or in Windows rename .jar file to .zip & then you can unzip to extract & view the content of jar file. As jar is internally a zip file.


In Eclipse 3.4 do

  1. Drag the jar file in question into a Java project. A copy of the jar file appears.
  2. Right click on the jar file, and choose "Build Path" -> "Add to Build Path".
  3. Jar file is moved to "Referenced Libraries" node, where it can be opened and navigated in the Project Explorer pane.

If seeing source code too is an issue, open a new question.

For navigation on Jar-file level (as a zip file) I use 7zip which works very well, and allows seeing and editing entries which is great for trouble shooting.


I've set the default action in windows to "Open with WinZip". This makes it easy to manage JARs as archives. You can even add/remove files manually.


Use WinRar. It will open the folder structure for you in intact manner. Also allows in-archive editing, while preserving paths.

Afterall, a JAR file is a ZIP archive only.


You can open them with most decompression utilities these days, then just get something like DJ Java Decompiler if you want to view the source.


You could try JarSpy. There is an IDEA plugin version of it that I use.


java -xf some-j.jar will unzip a JAR file.


I prefer JAR Browser, it has a simple interface where you can browse multiple JARs, and search for a specific class across multiple JARs simultaneously.


I've set the default action in windows to "Open with WinZip". This makes it easy to manage JARs as archives. You can even add/remove files manually.


Eclipse 3.4 JDT

It is not the quickest way because you have to drag it into your eclipse first. But you will have full java class browsing, even with decompile enabled.


You could try JarNavigator to view and search contents of a jar file.


On Mac there's Jarzilla


I prefer JAR Browser, it has a simple interface where you can browse multiple JARs, and search for a specific class across multiple JARs simultaneously.


This Jar Explorer is good enough.
Supports three decompiler types: JD, Procyon and Fernflower.
Allows to search files and duplicates in any java archive.
Also user can modify jar by D&D files and edit some non-class files. enter image description here enter image description here


One way to do this is to open the perspective in "Package explorer". Doing this you can see the structure of your jar with class details. For this check the library folder in your project using package explorer.

Window>>Show View>>Other>>Java>>Package Explorer

Another way is, you can use JarPlug as a eclipse plugin. This works in eclipse/springsource

http://jar-plug.sourceforge.net/


Jad is klunky and no longer maintained. I've switched to "Java Decompiler", which has a slick UI and support for new language features.

Every decompiler I've used, though, runs into code it doesn't successfully decompile. For those, it helps to understand the disassembled Java byte code produced by the standard JDK tool, javap.


If you like to see whats inside, simply rename as first option below..

  1. F2 & Rename to jarfile.zip //Use any unzipper...

  2. jar tvf jarfile.jar

  3. jar tf jarfile.jar


Extending Tom Hawtin answer, you can pipe the listing to filter out desired class or files:

jar tf my-fat-jar-file.jar | grep filename

This should work on bash/zsh and similars, or emacs' eshell.

Additional information: https://docs.oracle.com/javase/tutorial/deployment/jar/view.html


In Eclipse 3.4 do

  1. Drag the jar file in question into a Java project. A copy of the jar file appears.
  2. Right click on the jar file, and choose "Build Path" -> "Add to Build Path".
  3. Jar file is moved to "Referenced Libraries" node, where it can be opened and navigated in the Project Explorer pane.

If seeing source code too is an issue, open a new question.

For navigation on Jar-file level (as a zip file) I use 7zip which works very well, and allows seeing and editing entries which is great for trouble shooting.


Eclipse 3.4 JDT

It is not the quickest way because you have to drag it into your eclipse first. But you will have full java class browsing, even with decompile enabled.


Well, a jar-file is just a zip-file, so if you unzip it (with your favorite unzipping utility), you get all the files inside.

If you want to look inside the class files to see the methods, you'll need a tool for that. As PhiLho mentions, Eclipse is able to do that (by default), and I would think most Java IDEs are capable of that.


This Jar Explorer is good enough.
Supports three decompiler types: JD, Procyon and Fernflower.
Allows to search files and duplicates in any java archive.
Also user can modify jar by D&D files and edit some non-class files. enter image description here enter image description here


I prefer JAR Browser, it has a simple interface where you can browse multiple JARs, and search for a specific class across multiple JARs simultaneously.


Using the JDK, jar -tf will list the files in the jar. javap will give you more details from a particular class file.


You could try JarSpy. There is an IDEA plugin version of it that I use.


Well, a jar-file is just a zip-file, so if you unzip it (with your favorite unzipping utility), you get all the files inside.

If you want to look inside the class files to see the methods, you'll need a tool for that. As PhiLho mentions, Eclipse is able to do that (by default), and I would think most Java IDEs are capable of that.


If I understand correctly, you want to see not only classes but also methods, properties and so on. The only tool I know that can do it is Eclipse - if you add a jar to project classpath, you would be able to browse its classes with methods and properties using usual package explorer.

Anyway, this is a good idea for a good standalone Java tool


I use JarExplorer or JarVisualizer.


I prefer JAR Browser, it has a simple interface where you can browse multiple JARs, and search for a specific class across multiple JARs simultaneously.


In case someone don't know this already, a JAR file is just a ZIP file that contains the program's classes, resources, etc., and some metadata. You can extract one to see how it's put together.

Hence I am using unzip command which is easy to remember and use.

unzip -l <jar-file-name>.jar

For example, if you have a jar file with name test.jar then unzip -l test.jar will list all the content of jar file.

While all other answers are great, but in most of them, you would have to use some software like 7 zip or JDK or some other eclipse tool while this doesn't require you to have any of these big s/w and it comes by default in linux and mac so its very lightweight and handy to use.

You can also use zipinfo <your jar file>. if your OS supports this.


You could try JarNavigator to view and search contents of a jar file.


I usually open them with 7-Zip... It allows at least to see packages and classes and resources.
Should I need to see methods or fields, I would use Jad but of course, it is better to rely on (good) JavaDoc...

Now, somewhere on SO was mentioned some Eclipse plug-ins, to find in which jar file a class is located, perhaps they can do more (ie. what you requested).

[EDIT] Reference to SO thread. Not what is asked, but somehow related, thus useful: Java: How do I know which jar file to use given a class name?


In case someone don't know this already, a JAR file is just a ZIP file that contains the program's classes, resources, etc., and some metadata. You can extract one to see how it's put together.

Hence I am using unzip command which is easy to remember and use.

unzip -l <jar-file-name>.jar

For example, if you have a jar file with name test.jar then unzip -l test.jar will list all the content of jar file.

While all other answers are great, but in most of them, you would have to use some software like 7 zip or JDK or some other eclipse tool while this doesn't require you to have any of these big s/w and it comes by default in linux and mac so its very lightweight and handy to use.

You can also use zipinfo <your jar file>. if your OS supports this.


Method names, fields, etc.

By adding a jar to a project in an IDE, you can usually see methods and field names, but not the detailed implementation. NetBeans can do it, Eclipse probably, IntelliJ probably, etc. You can browse the jar structure directly within the IDE.

Just the contents

For anything such as viewing the contents, you could use :

  • jar tvf jarfile.jar
  • winzip or any zip tool

The source code

To access source code, you would use a decompiler such as JAD or one of its frontends or another decompiler. If the code is obfuscated, then ...


I usually open them with 7-Zip... It allows at least to see packages and classes and resources.
Should I need to see methods or fields, I would use Jad but of course, it is better to rely on (good) JavaDoc...

Now, somewhere on SO was mentioned some Eclipse plug-ins, to find in which jar file a class is located, perhaps they can do more (ie. what you requested).

[EDIT] Reference to SO thread. Not what is asked, but somehow related, thus useful: Java: How do I know which jar file to use given a class name?


If you are in windows and using powershell and you are looking for a file in a jar you can do:

jar -tf .\[JAR_NAME] | where {$_ -match "[FILENAME]"}

Extending Tom Hawtin answer, you can pipe the listing to filter out desired class or files:

jar tf my-fat-jar-file.jar | grep filename

This should work on bash/zsh and similars, or emacs' eshell.

Additional information: https://docs.oracle.com/javase/tutorial/deployment/jar/view.html


On Mac there's Jarzilla


If I understand correctly, you want to see not only classes but also methods, properties and so on. The only tool I know that can do it is Eclipse - if you add a jar to project classpath, you would be able to browse its classes with methods and properties using usual package explorer.

Anyway, this is a good idea for a good standalone Java tool


Eclipse 3.4 JDT

It is not the quickest way because you have to drag it into your eclipse first. But you will have full java class browsing, even with decompile enabled.



I've set the default action in windows to "Open with WinZip". This makes it easy to manage JARs as archives. You can even add/remove files manually.


My requirement was to view the content of a file (like a property file) inside the jar, without actually extracting the jar. If anyone reached this thread just like me, try this command -

unzip -p myjar.jar myfile.txt

This worked well for me!


If I understand correctly, you want to see not only classes but also methods, properties and so on. The only tool I know that can do it is Eclipse - if you add a jar to project classpath, you would be able to browse its classes with methods and properties using usual package explorer.

Anyway, this is a good idea for a good standalone Java tool


Using the JDK, jar -tf will list the files in the jar. javap will give you more details from a particular class file.


Your IDE should also support this. My IDE (SlickeEdit) calls it a "tag library." Simply add a tag library for the jar file, and you should be able to browse the classes and methods in a hierarchical manner.


I've set the default action in windows to "Open with WinZip". This makes it easy to manage JARs as archives. You can even add/remove files manually.


If I understand correctly, you want to see not only classes but also methods, properties and so on. The only tool I know that can do it is Eclipse - if you add a jar to project classpath, you would be able to browse its classes with methods and properties using usual package explorer.

Anyway, this is a good idea for a good standalone Java tool


You can open them with most decompression utilities these days, then just get something like DJ Java Decompiler if you want to view the source.


I use JarExplorer or JarVisualizer.


Well, a jar-file is just a zip-file, so if you unzip it (with your favorite unzipping utility), you get all the files inside.

If you want to look inside the class files to see the methods, you'll need a tool for that. As PhiLho mentions, Eclipse is able to do that (by default), and I would think most Java IDEs are capable of that.


Method names, fields, etc.

By adding a jar to a project in an IDE, you can usually see methods and field names, but not the detailed implementation. NetBeans can do it, Eclipse probably, IntelliJ probably, etc. You can browse the jar structure directly within the IDE.

Just the contents

For anything such as viewing the contents, you could use :

  • jar tvf jarfile.jar
  • winzip or any zip tool

The source code

To access source code, you would use a decompiler such as JAD or one of its frontends or another decompiler. If the code is obfuscated, then ...


You can open them with most decompression utilities these days, then just get something like DJ Java Decompiler if you want to view the source.


If you like to see whats inside, simply rename as first option below..

  1. F2 & Rename to jarfile.zip //Use any unzipper...

  2. jar tvf jarfile.jar

  3. jar tf jarfile.jar


I usually open them with 7-Zip... It allows at least to see packages and classes and resources.
Should I need to see methods or fields, I would use Jad but of course, it is better to rely on (good) JavaDoc...

Now, somewhere on SO was mentioned some Eclipse plug-ins, to find in which jar file a class is located, perhaps they can do more (ie. what you requested).

[EDIT] Reference to SO thread. Not what is asked, but somehow related, thus useful: Java: How do I know which jar file to use given a class name?


Jad is klunky and no longer maintained. I've switched to "Java Decompiler", which has a slick UI and support for new language features.

Every decompiler I've used, though, runs into code it doesn't successfully decompile. For those, it helps to understand the disassembled Java byte code produced by the standard JDK tool, javap.


Using the JDK, jar -tf will list the files in the jar. javap will give you more details from a particular class file.


I think Java Decomplier is your best option you can download from here: http://jd.benow.ca/ Preview


You could try JarSpy. There is an IDEA plugin version of it that I use.


If you are in windows and using powershell and you are looking for a file in a jar you can do:

jar -tf .\[JAR_NAME] | where {$_ -match "[FILENAME]"}

Using the JDK, jar -tf will list the files in the jar. javap will give you more details from a particular class file.



Bndtools provides a free JAR viewer plugin for Eclipse.

Add the Eclipse update site and install only the viewer.

enter image description here


One way to do this is to open the perspective in "Package explorer". Doing this you can see the structure of your jar with class details. For this check the library folder in your project using package explorer.

Window>>Show View>>Other>>Java>>Package Explorer

Another way is, you can use JarPlug as a eclipse plugin. This works in eclipse/springsource

http://jar-plug.sourceforge.net/


java -xf some-j.jar will unzip a JAR file.


I usually open them with 7-Zip... It allows at least to see packages and classes and resources.
Should I need to see methods or fields, I would use Jad but of course, it is better to rely on (good) JavaDoc...

Now, somewhere on SO was mentioned some Eclipse plug-ins, to find in which jar file a class is located, perhaps they can do more (ie. what you requested).

[EDIT] Reference to SO thread. Not what is asked, but somehow related, thus useful: Java: How do I know which jar file to use given a class name?


What I use personally is JD-GUI. It is a free 'decompiler', as it allows you to see the source code, classes, and objects in the classes, as well as see the file structure in a tree menu to the left. However, it does not allow you to modify the classes directly.

JD-GUI's website: http://jd.benow.ca/


Well, a jar-file is just a zip-file, so if you unzip it (with your favorite unzipping utility), you get all the files inside.

If you want to look inside the class files to see the methods, you'll need a tool for that. As PhiLho mentions, Eclipse is able to do that (by default), and I would think most Java IDEs are capable of that.


Your IDE should also support this. My IDE (SlickeEdit) calls it a "tag library." Simply add a tag library for the jar file, and you should be able to browse the classes and methods in a hierarchical manner.


Use WinRar. It will open the folder structure for you in intact manner. Also allows in-archive editing, while preserving paths.

Afterall, a JAR file is a ZIP archive only.


Bndtools provides a free JAR viewer plugin for Eclipse.

Add the Eclipse update site and install only the viewer.

enter image description here


Use WinRar. It will open the folder structure for you in intact manner. Also allows in-archive editing, while preserving paths.

Afterall, a JAR file is a ZIP archive only.


Your IDE should also support this. My IDE (SlickeEdit) calls it a "tag library." Simply add a tag library for the jar file, and you should be able to browse the classes and methods in a hierarchical manner.


I think Java Decomplier is your best option you can download from here: http://jd.benow.ca/ Preview


You can view JAR files like ZIP files from Windows Explorer by doing the following:

  • Run Command Prompt as Administrator
  • From the command line, enter:

    assoc .jar=CompressedFolder

  • While you are at it, you might as well do the same for WAR and EAR files:

    assoc .war=CompressedFolder

    assoc .ear=CompressedFolder


My requirement was to view the content of a file (like a property file) inside the jar, without actually extracting the jar. If anyone reached this thread just like me, try this command -

unzip -p myjar.jar myfile.txt

This worked well for me!


jar -tvf file_name.jar

above will only print names of the files.

To view the content of files, you can extract the files in a folder by:

jar -xvf file_name.jar

this will unzip jar file & put the content in same directory where you are running this.

Or in Windows rename .jar file to .zip & then you can unzip to extract & view the content of jar file. As jar is internally a zip file.