Creating a custom JRE with jlink
We will use the jlink
tool that is part of the Java JDK to create our custom JRE. We will begin by creating a JRE that contains all the required modules:
jlink --add-modules ALL-MODULE-PATH --output jdk-17.0.2-jre --strip-debug --no-man-pages --no-header-files --compress=2
This is one line. In Linux, you can enter a multiline command using the backslash (\
), while in Windows, you use the caret (^
). The output of this command will be a folder named jdk-17.0.2-jre
that contains a JRE of only 76 MB. This is smaller than the original JRE, but we do not want all the Java modules; we just need three. Here is our new command:
jlink --add-modules java.base,java.desktop,java.logging --output jdk-17.0.2-minimaljre --strip-debug --no-man-pages --no-header-files --compress=2
We will now have a new JRE in the...