JAR Command Utility
The JAR (Java Archive) tool is a package file format that aggregates many files into one. It is used for library utilities, application deployment, and to package related resources such as metadata, text, and translations. This page provides essential commands for managing JAR files.
Archive Files into a JAR
To archive all files in the current directory into a JAR file, use the cf option.
jar cf <file.jar> *
Create JAR with Manifest File
To create a JAR file using a pre-existing manifest file, which can specify entry points and other metadata, use the cfm option.
jar cfm <file.jar> <manifest_file> *
Extract All Files from a JAR
To extract all files from a JAR file into the current directory, use the xf option.
jar xf <file.jar>
Extract Specific Files from a JAR
To extract only certain files from a JAR file, specify the file names after the JAR file name.
jar xf <file.jar> <file_to_extract>
List Content of a JAR File
To list the content of a JAR file without additional details, use the tf option.
jar tf <file.jar>
List Content of a JAR File (Verbose)
To list the content of a JAR file with verbose output, including details like file size and modification time, use the tf option.
jar tf <file.jar>