2

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).

GoForce5500
  • 111
  • 1
  • 7
  • In what case we need a cropped jre? – ZhaoGang Dec 30 '18 at 08:03
  • @ZhaoGang Maybe in a docker image or on a raspberrry pi? More quickly and less cumbersome. – GoForce5500 Dec 31 '18 at 10:30
  • @ZhaoGang because there is not public installable JRE > java 8 available to download. So if you develop an app using java > 8, you are obligated to create a cropped JRE –  Jul 04 '19 at 17:35

1 Answers1

1

I guess jdeps just can't handle jars recursively. Try to unpack your fat jar and run jdeps --list-deps on each of jars in <fat jar root>/lib dir.

Konstantin Labun
  • 3,688
  • 24
  • 24
  • You're right, but when I try it I encounter another problem-- https://bugs.openjdk.java.net/browse/JDK-8207162 which prevent me from using multi-version jars(such as log4j) with jdeps. – GoForce5500 Dec 31 '18 at 11:24