The recommended deployment practice for Java these days (embedded custom runtime, created with jlink) never requires any pre-installed runtime. The end-user should never install a runtime separately from the application.
How is the "recommended" deployment practice something most don't use?
Because it's relatively new.
You'll probably still use java -jar with jlink images, too (unless your application is modularised), it's just that the runtime is very small and is part of the app.
Is there a Spring Boot starter or guide to use jlink?
The only thing you'll need to do different is list more JDK modules at the end. You figure out which modules you use with jdeps (this step is unnecessary if your application is modularised, but most aren't).
ou figure out which modules you use with jdeps (this step is unnecessary if your application is modularised, but most aren't).
If you are using Gradle, here is a small task that prints the modules required for your jar (or uberjar)
val printModuleDeps by tasks.registering {
description = "Print Java Platform Module dependencies of the application."
group = LifecycleBasePlugin.BUILD_TASK_NAME
doLast {
val uberJar = named("shadowJar", Jar::class)
val jarFile = uberJar.get().archiveFile.get().asFile
val jdeps = ToolProvider.findFirst("jdeps").orElseGet { error("jdeps not found") }
val out = StringWriter()
val pw = PrintWriter(out)
jdeps.run(pw, pw, "--print-module-deps", "--ignore-missing-deps", jarFile.absolutePath)
val modules = out.toString()
println(modules)
}
dependsOn("shadowJar")
}
16
u/pron98 Mar 11 '21
The recommended deployment practice for Java these days (embedded custom runtime, created with jlink) never requires any pre-installed runtime. The end-user should never install a runtime separately from the application.