Inspecting and extracting JAR files from the command line

Mar 15, 2017 • packagecloud

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

Easy to use Maven repositories, free.

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.

Never miss an update!

Subscribe to our RSS feed