Please see my slides for why I came to this conclusion.
Information additional to the slides is below.
And here’s how to get started with GraalVM Native Image – or “Native Java”, as I call it:
The Aspiring Speakers regulary hosts online lightning talks. I’ll talk there on Tuesday, September 5, 2023 about “Why Is Java in the Cloud So Expensive – And How Can I Make It Cheaper?”.
Here are the slides as PDF. They are just 202 KB:
You can also get the slides in their original Keynote format. “Keynote” is Apple’s presentation application. Why would you do that? My slides have less text than the PDF version, so you can see what I cut. I also animated the slides, so they are more pleasant to watch. Or maybe you want to peek under the hood to see how I achieved specific effects. These slides are 3.5 MB.
Here’s my page for getting started with native Java.
The section is slightly out-of-date, as it doesn’t use the latest GraalVM release. I’ll update once the next GraalVM release drops in the middle of September. In the meantime, you can also read my InfoQ news item about the latest GraalVM release. It includes an interview with Alina Yurenko, developer advocate for GraalVM at Oracle Labs.
Class Sharing for OpenJDK 17 is documented here. It comes down to three steps:
-Xshare:off and -XX:DumpLoadedClassList=hello.classlist. This does not run your program, it just creates the list.java -Xshare:off -XX:DumpLoadedClassList=hello.classlist -cp hello.jar
java -Xshare:dump -XX:SharedArchiveFile=hello.jsa -XX:SharedClassListFile=hello.classlist -cp hello.jar
java -XX:SharedArchiveFile=hello.jsa -cp hello.jar
Please see my InfoQ news item about CRaC for information on how to get started. It includes an interview with Simon Ritter, the driving force behind CRaC.
I measured the GraalVM Native Image improvements in startup time and memory consumption with a demo app I wrote. The demo application converts images to PDFs. It’s available for Spring Boot 2 & 3, Quarkus, and Go. Check it out below.