-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
P4
-
None
-
Affects Version/s: 11
-
Component/s: tools
Starting Java 11 through versions Java 21, the "jar --help" text and the man page of that tool (for example here https://docs.oracle.com/en/java/javase/21/docs/specs/man/jar.html#operation-modifiers-valid-in-any-mode) state the following:
Operation Modifiers Valid in Any Mode:
You can use the following options to customize the actions of any operation mode included in the jar command.
-C DIR
Changes the specified directory and includes the files specified at the end of the command line.
jar [OPTION ...] [ [--release VERSION] [-C dir] files]
That's not accurate since -C cannot be used for the extract (-x) operation.
For example, consider the following jar contents:
jar -tf foo.jar
META-INF/
META-INF/MANIFEST.MF
1/
1/1.txt
2/
2/2.txt
Running:
jar -xvf foo.jar -C 1
gives an error:
Error parsing file arguments
Try `jar --help' for more information.
and running:
jar -xvf foo.jar -C 1 1.txt
extracts nothing. The help text and man page should be updated to fix that text.
Do note that starting Java 24, after https://bugs.openjdk.org/browse/JDK-8173970, does indeed support the -C operation modifier for the extract operation. It uses -C as the destination directory into which the contents of the JAR file are extracted. So this issue only applies to versions before Java 24.
Operation Modifiers Valid in Any Mode:
You can use the following options to customize the actions of any operation mode included in the jar command.
-C DIR
Changes the specified directory and includes the files specified at the end of the command line.
jar [OPTION ...] [ [--release VERSION] [-C dir] files]
That's not accurate since -C cannot be used for the extract (-x) operation.
For example, consider the following jar contents:
jar -tf foo.jar
META-INF/
META-INF/MANIFEST.MF
1/
1/1.txt
2/
2/2.txt
Running:
jar -xvf foo.jar -C 1
gives an error:
Error parsing file arguments
Try `jar --help' for more information.
and running:
jar -xvf foo.jar -C 1 1.txt
extracts nothing. The help text and man page should be updated to fix that text.
Do note that starting Java 24, after https://bugs.openjdk.org/browse/JDK-8173970, does indeed support the -C operation modifier for the extract operation. It uses -C as the destination directory into which the contents of the JAR file are extracted. So this issue only applies to versions before Java 24.