Back to Posts
Packagecloud logo

Inspecting and extracting JAR files from the command line

Table of Contents

  1. TL;DR
  2. Extract JAR file
  3. Extract JAR file without jar command line tool
  4. List files in JAR file
  5. List files in JAR file without jar command line tool
  6. Conclusion

TL;DR

This post covers how to extract and list the contents of JAR files using the command line.

 

Extract JAR file

$ jar xvf /path/to/file.jar

 

Extract JAR file without jar command line tool

JAR files are Zip files but with a different name. You can use any program that can read Zip files to extract them.

$ unzip /path/to/file.jar

NOTE: You may need to rename the file to end with ‘.zip’ for some programs to extract them.

 

List files in JAR file

$ jar tvf /path/to/file.jar

 

List files in JAR file without jar command line tool

$ unzip -l /path/to/file.jar

 

Conclusion

JAR files are Zip files, so any program that can read Zip files can also read JARs. In some cases, you may need to rename the JAR file to end with “.zip” for certain tools that can read Zip files to work.

Hungry for more knowledge?

Related posts