New post: Using jlink to cross-compile minimal JREs
https://jakewharton.com/using-jlink-to-cross-compile-minimal-jres/
I've been doing this inside Docker containers for a while to keep their size down, but recently needed it to target an embedded Linux ARM device with only 100MiB of storage.
@jw I tried that for some service we're deploying to kubernetes at work. It took far too much trial and error for me to feel safe that I didn't miss anything (to a point I ran into bugs of jlink in JDK16 or 17 can't remember exactly), and I decided it wasn't worth the effort. Yes, it reduces the attack surface due to less code, and there's faster download.. but do people really go the extra mile for Docker images?
@oliver__t Yeah libraries with heavy usage of reflection or which try to conditionally adapt to the JDK do not always communicate clearly to the jdeps tool. It's easy enough to add an explicit entry, but I actually ended up swapping out Jetty because my service was very low throughput. Obviously not everyone has such freedoms.