JLink packaging
experimentalThe jlink extension produces a custom Java runtime image for a Quarkus application.
The image contains only the JDK modules and application modules that are needed to run the application, resulting in a smaller, faster, and more self-contained distribution.
This extension depends on the Quarkus modularity extension to compute the application’s module graph.
|
这项技术被认为是experimental。 在 experimental(实验) 模式下,要求早期反馈以使想法成熟。在解决方案成熟之前,不保证稳定性或长期存在于平台中。欢迎在我们的 邮件列表 中提供反馈,或在我们的 GitHub问题列表 中提出问题。 For a full list of possible statuses, check our FAQ entry. |
Prerequisites
The jlink extension requires Java 25 or later.
Earlier JDK versions have compatibility issues with the jlink tool that prevent reliable image generation.
Usage
Add the quarkus-jlink extension to your project.
When the extension is present, a jlink image is produced automatically as part of the normal Quarkus build.
JAR packaging is disabled when jlink is active.
quarkus extension add quarkus-jlink
./mvnw quarkus:add-extension -Dextensions='quarkus-jlink'
./gradlew addExtension --extensions='quarkus-jlink'
After adding the extension, build the project normally:
quarkus build
./mvnw install
./gradlew build
The jlink image is written to the output directory (by default, target/jlink-output/image).
Running the image
To run the application, execute the launcher script in the image’s bin directory:
./target/jlink-output/image/bin/<launcher-name>
The launcher name currently defaults to my-app.
A future release will derive the default from quarkus.package.output-name.
Image layout
The output directory has the standard jlink image structure.
The bin/ directory contains the launcher script.
The lib/ directory contains the JDK runtime modules.
Application modules that are not on the boot module path are placed in lib/quarkus/ and are loaded dynamically on demand after startup by smallrye-modules.
See the modularity guide for an explanation of boot modules and dynamic modules.
Configuration reference
Configuration property fixed at build time - All other configuration properties are overridable at runtime
Configuration property |
Type |
Default |
|---|---|---|
Whether Environment variable: Show more |
boolean |
|
The minimum heap size to configure for the image. If not given, no minimum heap size is specified. Environment variable: Show more |
||
The maximum heap size to configure for the image. If not given, no maximum heap size is specified. Environment variable: Show more |
||
The image output path. If relative, it will be resolved in terms of the packaging output path. Environment variable: Show more |
path |
|
The name of the launcher script generated in the image’s Environment variable: Show more |
string |
|
The base output directory for the Environment variable: Show more |
path |
|
The path of the staging directory used during the Environment variable: Show more |
path |
|
|
About the MemorySize format
A size configuration option recognizes strings in this format (shown as a regular expression): If no suffix is given, assume bytes. |