- Some Background
- Creating JAR Files
- Viewing Contents of Your JAR File
- Extracting Contents of a JAR File
- Updating Your JAR Files
- Sealing Packages in JARs
- JAR Indexing
Extracting Contents of a JAR File
As you probably guessed, extraction of the contents of a JAR file is not that hard either. The syntax below shows the basic command structure you would use:
jar xf jar-filename.jar [optional, space-delimited names of specific archived files]
In the syntax above, we use the JAR tool with the x option, indicating we want to perform an extraction. The f option indicates that we want our extraction to occur from the filename we specify (i.e., jar-filename.jar).
We can append the command with filenames of specific files that are housed in the archive which we want extracted. This is particularly useful if we are only interested in grabbing a subset of the files housed in our archive. By not specifying any specific file names, the tool goes ahead and extracts all the files in the archive.
When the extraction process occurs, the JAR tool automatically creates any directories that it sees were stored in the archive. It is also very important to take note: any existing files with the same name will be overwritten if there is a duplicate entry in the target extraction destination. The user is not prompted that an overwrite is occurring, so users should be prudent when using the tool.