The fat jar works well and I just want to use a cropped JRE.
I tried with following:
jdeps --list-deps {my fat jar}
The result I got is:
java.base
java.logging
If I use that to make my own JRE using jlink --no-header-files --no-man-pages --compress=2 --strip-debug --add-modules java.base,java.logging --output cropped-jre
, the new JRE just can't satisify the fat jar.
Actually, it needs other dependencies as well as "java.sql" for example.
The tree view of the fat jar is:
jar tf {my fat jar}
META-INF/
META-INF/MANIFEST.MF
org/
org/springframework/
org/springframework/boot/
......
BOOT-INF/
BOOT-INF/classes/
BOOT-INF/classes/templates/
BOOT-INF/lib/{spring/netty/etc.jar}
......
How can I got all those dependency with jdeps?
When you try to avoid this, you may try to unzip your fat jar and point it's lib to jdeps, but then you'll encounter another bug --https://bugs.openjdk.java.net/browse/JDK-8207162, which prevents you from using multi-version jars(such as log4j) with jdeps. Finally I tried every dependency to find an answer: jlink --no-header-files --no-man-pages --compress=2 --strip-debug --add-modules java.base,java.logging,java.management,java.sql,java.transaction.xa,java.xml,java.naming,java.desktop,java.security.jgss,java.instrument,jdk.unsupported --output java-base That will generate a cropped JRE(only 40MB, based on openJDK11) which could run your spring-boot application(with Tomcat/Thymeleaf/Jedis).