Creating native image with micronaut and graalvm

I am a developer who loves Java, Spring, Quarkus, Micronaut, Open source, Microservices, Cloud
Search for a command to run...

I am a developer who loves Java, Spring, Quarkus, Micronaut, Open source, Microservices, Cloud
No comments yet. Be the first to comment.
Micronaut is one of the promising java based frameworks in the Microservices space. Here is a series that I have started on Microservices framework based on Micronaut.
Micronaut JDBC Data in action
Spring AI Tool Calling: From Chatbot to AI Agent with @Tool Your AI is smart. It knows an enormous amount. But it's frozen. It doesn't know what time it is right now. It doesn't know what's on your ca
Spring AI Advisors API Explained Series: Spring AI Complete Course — Lecture 4 of 12Reading Time: 8 minutesLevel: Intermediate Most developers stop at ChatClient. That is enough for demos. It is not
Working with Multiple AI Models in Spring AI Spring AI Complete Course — Lecture 3 of 12Previous: Lecture 2 — ChatClient API | Next: Lecture 4 — Advisors API In production AI applications, you rarel
Spring AI ChatClient API: The Fluent Heart of AI Integration Introduction If you've ever tried integrating AI models into a Java application, you know the pain. HTTP clients, API keys scattered everywhere, vendor-specific SDKs that never quite fit. W...
What is Spring AI? — Why Java Developers Need This in 2026 Every AI tutorial you see is in Python. LangChain, LlamaIndex, OpenAI SDK — all Python. But here's the uncomfortable truth: 80% of enterprise backends run Java. So who's building AI into thos...
In last section we saw , how easy it was to create a project with micronaut. We created our universe savior heroes and called them through our url /super-heroes with their powers .If you have not checked it, you can take a look at below link.
https://blog.codingsaint.com/micronaut-the-starting-your-first-project
The world these days are moving at fast pace. To start our system it was taking almost 3 seconds. What if it turns out to be too much to call these saviors. Graalvm is there to rescue. We will build native images in this article and start our system in milliseconds. In order to build native image we require graalvm . To install graalvm on your system there are several ways , but now let's use the easy one SDKMAN. If you have not installed SDKMAN , please do it. Its awesome. https://sdkman.io/
To check list of available jdks use following command
sdk list java
From the list choose the graalvm

Here we will choose 21.2.0.r16-grl
Use the below command to install the graalvm SDK
sdk install java 21.2.0.r16-grl
Once It is installed , we need to add native image building capabilities to it.
gu install native-image
Now we are ready to create native images. Use the following command
./mvnw package -Dpackaging=native-image
This step might take sometime depending upon you system configurations.
Once done you will see inside target folder there will be a new native binary present . Use it to start the application
It our case application name is super-heroes so native is also named same.
./target/super-heroes
You will see logs as following

Clearly you can see it started in 64 milliseconds which is around 47 times faster than our older effort , which was at 3028 ms , below is the screenshot of running jar than binary.

If you like my articles you can support me by sharing the articles with your friends, twitter, facebook or any other social media. You can also buy me a coffee