GraalVM for Java Developers: The Ultimate Beginner’s Guide

 

Transcript:

How to turn your Jaw project into a cool Lego construction set that will make kids envious. The answer is,  GraalVM.  GraalVM Is it just another JVM? Well, actually not. It is much more Want a performance boost? Try out grow VM JEP compiler. Want an almost instant startup? Give a try to  GraalVM native image. Want to mix and match various languages? Try out the truffle framework. In this video, we'll look at all three components and get the answers to the questions. What, why, how and where.

 GraalVM JEP compiler is a dynamic compiler written mainly in Java and based on top of Hotspot JVM, but as opposed to Hotspot C1 and C2 compilers, it includes more optimizations. More aggressive inlining data flow analysis, better escape analysis, and so on. As a result, it can provide better performance for some workloads than C one and C two compilers. You can run your code on Graal VM just like on any other JVM. No code refactoring, no incompatibilities. All dynamic features of Java are supported TCK verification, all JVM goodies, such as the variety of Garbage Collectors and so on. But your program can potentially run faster, have better throughput, and require less resources. Any limitations? Well, of course, it's not a magic pill. Some applications will have the same performance. In some cases, you may have to tune the GraalVM compiler for better results. How do you use Graal compiler? Simply download the GraalVM distribution and use it just like any other JDK to run and compile your application. Spoiler alert: there is not one but several GraalVM distributions, but I will reveal the difference later in this video. Stay tuned! Alright, we accelerated Java coup, but what if you want to write polyglot applications or run your own language on top of GraalVM?

In come the Polyglot API and the Truffle Framework. The Truffle Framework is a tool for building tools and implementations of programming languages that you can run on top of GraalVM. There are several ready implementations for GraalVM : GraalPy for Python, GraalJS, TruffleRuby, GraalWASM, and even GraalVM LLVM runtime for C and like. And you can implement your own language and truffle. How about implementing Brain____ truffle and using it in your Java app? Sounds like a cool weekend project. Well, jokes aside, truffle lets you implement various languages in one application and benefit from them all. And you can also build language agnostic tools such as profilers or debuggers. All right, but what about the polyglot API? It lets you embed code from the guest languages into a host Java application or embed Java code into the application written other languages. You can run code from any language implemented on truffle in a host Java Applic. Any limitations, traps, caveats. I know it sounds too good to be true. So here are some things to consider. Implementing your own language sounds cool, but it's not a one hour task. You get the tools, but you have to carve the sculpture yourself. Not all the tools and libraries for guest programming languages are available, but otherwise, GraalVM makes your Java app a hospitable host for any guest language.

Just don't let them quarrel our politics. Here comes the most hyped part of GraalVM. GraalVM Native Image. GraalVM native image compiles Java application at build time and turns it into a platform specific, fully compiled and optimized executable. That starts up almost instantly, so there's no warmup or memory overhead. It doesn't require a JVM to run. It has smaller footprint. And it has a smaller attack surface because all unrequired components were cut off during the compilation. Native image can be very useful in serverless environments. Last most GraalVM limitations are related to native image. It requires more effort to use a grom native ture with Java applications that rely heavily on Java dynamic features. Although it's not impossible, it means that you may have to tame a dragon or two. It may not be suitable for applications deeply tied into the JVM internals, and it is not a JVM, meaning there is no dynamic performance optimization as there is no JEP compiler at run time. There is a limited choice of garbage collectors. And you will have to get a knack for debugging and profiling native images. So how do you deal with reflection and its dynamic? Friends, you need to specify all cases of, uh, the usage of dynamic features in a special. Config file that will be read by the native image compiler. You can use the tracing agent that will track all the usages of dynamic features while you run your application in a test environment through all possible execution paths, and then it'll create a file automatically. But unfortunately, even the tracing agent may not always notice the usage of the dynamic features. What can I say? This is an exciting journey and if you really need what awaits you at the end, it is definitely worth going through. And now as promised, what is the difference between GraalVM distributions?

Cut to the Chase GraalVM community is free open source and is suitable for most use cases. Oracle GraalVM offers more optimizations, but it may not be free in some cases. Please read the license carefully. Plus, there are two downstream distributions of GraalVM Community Edition. Liberica Native Image Kit by BellSoft and Mandrel by Red Hat. Liberica Native Image Kit is recommended by Spring and is used by default in spring build pack. It also provides builds with Java effects. Manl includes only the native image part and is optimized for cos. So if you want to use a free version, but you may need technical support somewhere in the future. I suggest you try out these bad boys about the updates. Oracle GraalVM LTS is updated for free for three years and after that you have to either migrate to a newer LTS version or pay for support. GraalVM community provides updates only for the latest Java version, Liberica Native Image Kit and Mangel receive support for LTS versions for a longer period of time.

Consult their product support cycles. Let's summarize implementations applied to native image. There is no dynamic performance optimization. The choice of garbage collectors is limited, and the build process is resource and time consuming. When to use Jeep or native image. Git compiler is great for long running AppCDS and dynamic workloads. Native image is optimal for serverless computing and services characterized by short runs. Can we combine polyglot and native image? Generally? Yes, but all solutions must support a AOT mode. Sounds complicated. Well, actually it's not. Just choose a component and try it out. I hope I convinced you that grow is not just another JVM. It is a powerful solution for various engineering needs. Try out the component that best fits your needs and see it in action on your project. Don't forget to like, subscribe, and until next time.

Summary

In this video, GraalVM is presented as more than just another JVM. It offers a JIT compiler for better performance, a Polyglot API and Truffle framework for mixing languages, and a Native Image tool for creating fast, lightweight executables. While Native Image is great for serverless and short-lived apps, it has limitations like restricted dynamic features and fewer garbage collectors. GraalVM comes in different distributions such as Community, Oracle, Liberica, and Mandrel, each with its own benefits and support options.

About Catherine

Java developer passionate about Spring Boot. Writer. Developer Advocate at BellSoft

Social Media

Videos
card image
Jul 15, 2025
Java Downgrade Challenge: From JDK 8 to 1.1 (Part 2)

In Part 2 of the Java Downgrade Challenge, we continue our journey — now from Java 8 all the way to Java 1.1. No streams, no lambdas, no generics, no collections — and at one point, we even boot up Windows 98. If you thought Part 1 was painful, this one unwinds Java history line by line. By the end, the familiar Java from today will be almost gone.

Videos
card image
Jun 27, 2025
5x Smaller Java Docker Images — 2025 Optimization Guide

In this video, I’ll show you how to make your Java Docker images 5 TIMES SMALLER. You’ll see the full process, from a heavy 587MB container to a lean 116MB image, ready for production.

Further watching

Videos
card image
Aug 27, 2025
Buildpacks for Spring Boot

Buildpacks for Spring Boot: no Dockerfiles, no hassle — just production-ready container images in one command. Tired of maintaining Dockerfiles? In this tutorial, you’ll learn how to use buildpacks to create optimized Spring Boot containers — fast, secure, and cloud-ready — with just one command. We’ll show what happens under the hood: automatic dependency detection, layered image creation, memory tuning, SBOM generation, and how to tweak builds with just a few plugin options. Need faster startup, smaller image size, or JFR monitoring? Buildpacks can handle it — and we’ll show you how.

Videos
card image
Aug 20, 2025
Flyway in Spring Boot: Step-by-Step tutorial with Maven

Learn how to use Flyway in Spring Boot with Maven for smooth and reliable database migrations. In this hands-on tutorial, we cover everything from setting up PostgreSQL in Docker, configuring Flyway in your application, writing versioned and repeatable migrations, to using Flyway in CI/CD pipelines with GitHub Actions. Whether you’re new to Flyway or want to master schema version control in Spring Boot, this video will guide you step by step.

Videos
card image
Aug 14, 2025
Stop Using DTOs – A Cleaner Way for Your Java APIs

Still creating DTOs for every API in your Spring Boot project? You might be overcomplicating things. In this video, we show why DTOs aren’t always necessary and how to replace them with @JsonIgnore, @JsonView, and Jackson Mixins. You’ll see real examples of hiding sensitive fields, creating role-based views, and cutting boilerplate — all while keeping your API safe, clean, and easy to maintain.