[Java] Create a jar file with both compressed and uncompressed with the jar command

There is only a JDK ...

** Environment without build tools ** (only JDK can be used) Some of the resources (no compilation required) included in the Spring Boot executable jar file (Is fat jar the official name?) A note when ** replacement ** is needed and ** managed with the ** jar command **.

Immediate response

I didn't have much time, so I came up with the method I did with ** Eh **.

Work path configuration (partial)


+ (Working directory)
  + work
    + BOOT-INF
      + classes
      + lib
    + META-INF
      + MANIFEST.MF
    + org
      + springframework
        + ...

command


jar cvfm0 Hoge.jar ./work/META-INF/MANIFEST.MF -C ./work .

I have an executable jar file, but the 0 option makes ** all files uncompressed **, which causes the file size to grow ** several times **. .. ..

A decent response

I wanted to uncompress only the jar files under BOOT-INF / lib, so I tried to find out how to do it after calming down.

As a preliminary preparation, move only the jar files under BOOT-INF / lib to another path.

Working path configuration (partly BOOT-INF/(After moving lib)


+ (Working directory)
  + work
    + BOOT-INF
      + classes
    + META-INF
      + MANIFEST.MF
    + org
      + springframework
        + ...
  + work2
    + BOOT-INF
      + lib

command


jar cvfm Hoge.jar ./work/META-INF/MANIFEST.MF -C ./work .
jar uvf0 Hoge.jar -C ./work2 .

Just like the original jar file, we now have an executable jar file that contains only the jar files under BOOT-INF / lib uncompressed.

Recommended Posts

[Java] Create a jar file with both compressed and uncompressed with the jar command
Create a jar file with the command
Create a Jar file with two lines of command
How to create a jar file or war file using the jar command
[Java] Create a temporary file
About the behavior when doing a file map with java
When a Java file created with the Atom editor is garbled when executed at the command prompt
Create a Maven project with a command
Create a simple web server with the Java standard library com.sun.net.httpserver
Create a high-performance enum with fields and methods like Java with JavaScript
Create a flyway jar with maven and docker build (migrate) with docker-maven-plugin
Create a large number of records with one command using the Ruby on Rails seeds.rb file
[Java] Create and apply a slide master
[Java8] Search the directory and get the file
Create a Spring Boot app development project with the cURL + tar command
The story of forgetting to close a file in Java and failing
How to create a server executable JAR and WAR with Spring gradle
<java> Split the address before and after the street address with a regular expression
How to download and run a Jar package directly from the Maven repository with just the command line
JAVA: jar, aar, view the contents of the file
Read a string in a PDF file with Java
Create a CSR with extended information in Java
Let's make a calculator application with Java ~ Create a display area in the window
[Windows] [IntelliJ] [Java] [Tomcat] Create a Tomcat9 environment with IntelliJ
Let's create a timed process with Java Timer! !!
Getting started with Gradle (until you create a Java project and combine external libraries into one executable JAR)
[Java] Create a collection with only one element
[Note] Java: Create a simple project while learning how the configuration file works.
Create a multi-key map with the standard library
Getting started with Maven (until you create a Java project and combine external libraries into a single executable JAR)
Compile and run Java on the command line
Prepare a scraping environment with Docker and Java
[Java] Convert and import file values with OpenCSV
When I call the file with Class # getResource from the jar file, it becomes Not Found and it is a crappy memorandum
I tried to create a shopping site administrator function / screen with Java and Spring
Create a Java (Gradle) project with VS Code and develop it on a Docker container
How to save a file with the specified extension under the directory specified in Java to the list
Create a Java (Maven) project with VS Code and develop it on a Docker container
[Java] Cut out a part of the character string with Matcher and regular expression
Create a Java Servlet and JSP WAR file to deploy to Apache Tomcat 9 in Gradle
Form and process file and String data at the same time with Spring Boot + Java
[Java] Let's create a mod for Minecraft 1.14.4 [0. Basic file]
Create a portfolio app using Java and Spring Boot
Include image in jar file with java static method
[Beginner] Create a competitive game with basic Java knowledge
[Java] Let's create a mod for Minecraft 1.16.1 [Basic file]
[Java] Get the file in the jar regardless of the environment
[Java] Get the file path in the folder with List
I tried OCR processing a PDF file with Java
[Note] Create a java environment from scratch with docker
21 Load the script from a file and execute it
Prepare the environment for java11 and javaFx with Ubuntu 18.4
Create a JAVA WEB application and try OMC APM
[Java] Create a filter
java jar classpath command
Let's create a file upload system using Azure Computer Vision API and Azure Storage Java SDK
I want to get a list of the contents of a zip file and its uncompressed size
The story of building a Java version of Minecraft server with GCP (and also set a whitelist)
Until you build a project described in scala with Maven and execute it with the scala command.
Create a blog with Jekyll and GitHub Pages @ Theme setting
Generate and execute Jar file of Java file belonging to package