IBM Support

Using the Jar Command to Unzip Files

Troubleshooting


Problem

This document explains how to decompress a file in the IFS using the "jar" command.

Resolving The Problem

The following syntax shows an example of the Java ARchive ("jar") command, in Qshell, to decompress a compressed file:

To start the Qshell environment, execute "QSH" on a CL command line.

jar -xvf /Directory/File.zip
   -x  extract named (or all) files from archive
   -v  generate verbose output on standard output
   -f  specify archive file name         
       

Note: The 'jar' command extracts to the current directory.

The following is a work-around:

Change the current directory to the target directory before running the jar command:
cd /Target_Directory; jar -xvf /Directory/File.zip
The semicolon ( ; ) is used to separate commands, but to still have them on the same line.
To extract only specific files from an archive, supply their file names:
jar -xvf /Directory/File.zip foo.txt bar.txt

The following example is from an IBM i command line or CL program
Note: This command decompresses only standard compression algorithms. 
QSH CMD('cd /Target_Directory;jar -xvf /Directory/File.zip')
See Related URLs for IBM i command line alternatives.

[{"Type":"MASTER","Line of Business":{"code":"LOB57","label":"Power"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG60","label":"IBM i"},"ARM Category":[{"code":"a8m0z0000001jUYAAY","label":"Integrated File System-\u003ECommands"}],"ARM Case Number":"TS009407001","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"All Versions"}]

Historical Number

392647837

Document Information

Modified date:
24 May 2022

UID

nas8N1015312