JAR does not store (or preserves after extraction) file permissions such as for executable shell scripts.
With the increasing adoption of Docker and Linux containers in general, images for Java programs must of course have JRE installed. But Java-based programs are commonly distributed as ZIP files. While developers can use JAR to extract, the program does not restore file permissions, which may break usage of some files, especially shell scripts. Developers then have to install unzip to use it only once to extract the zipped Java program, to then later just remove the unzip tool right away.
If JAR can extract ZIP files, it should support key expected behaviors of `unzip`, such as, of course, restore file permissions.
In terms of the container use case, here's an example of a Dockerfile snippet:
FROM ...
ENV ...
COPY ...
RUN yum -y install unzip && \
unzip -o $GLASSFISH_PKG && \
rm -f $GLASSFISH_PKG && \
yum -y remove unzip
In the code above, unzip is used only once. Meanwhile, JDK will be installed and always present because this is a Java program, and thus JAR could've been used if only it could preserve file permissions such as executable shell scripts (like "asadmin" from GlassFish).
Users are often trying to use JAR instead of unzip, but failing due to this exact reason:
- http://stackoverflow.com/questions/28178375/creating-a-jar-file-preserving-file-permissions
- http://stackoverflow.com/questions/1050560/maintain-file-permissions-when-extracting-from-a-zip-file-using-jdk-5-api
- https://community.oracle.com/thread/1565035?start=0&tstart=0
- http://www-01.ibm.com/support/docview.wss?uid=swg21227729
There is a good number of results if one runs the following search on Google:
- https://www.google.com/search?q=jar+extract+preserve+permissions
Other related bugs reported:
-JDK-6194856
-JDK-4071752
-JDK-4097578
With the increasing adoption of Docker and Linux containers in general, images for Java programs must of course have JRE installed. But Java-based programs are commonly distributed as ZIP files. While developers can use JAR to extract, the program does not restore file permissions, which may break usage of some files, especially shell scripts. Developers then have to install unzip to use it only once to extract the zipped Java program, to then later just remove the unzip tool right away.
If JAR can extract ZIP files, it should support key expected behaviors of `unzip`, such as, of course, restore file permissions.
In terms of the container use case, here's an example of a Dockerfile snippet:
FROM ...
ENV ...
COPY ...
RUN yum -y install unzip && \
unzip -o $GLASSFISH_PKG && \
rm -f $GLASSFISH_PKG && \
yum -y remove unzip
In the code above, unzip is used only once. Meanwhile, JDK will be installed and always present because this is a Java program, and thus JAR could've been used if only it could preserve file permissions such as executable shell scripts (like "asadmin" from GlassFish).
Users are often trying to use JAR instead of unzip, but failing due to this exact reason:
- http://stackoverflow.com/questions/28178375/creating-a-jar-file-preserving-file-permissions
- http://stackoverflow.com/questions/1050560/maintain-file-permissions-when-extracting-from-a-zip-file-using-jdk-5-api
- https://community.oracle.com/thread/1565035?start=0&tstart=0
- http://www-01.ibm.com/support/docview.wss?uid=swg21227729
There is a good number of results if one runs the following search on Google:
- https://www.google.com/search?q=jar+extract+preserve+permissions
Other related bugs reported:
-
-
-