Documentation

Documentation versions (currently viewingVaadin 24)

Native Image Compilation with GraalVM

How to compile a Vaadin Flow application into a native image using GraalVM.

For Spring Boot-based applications, Vaadin supports native image compilation with GraalVM. By compiling your application into a native image, you can benefit from much faster startup times (milliseconds) and lower memory consumption compared to running the application on the JVM.

Requirements

Before you begin, ensure you have a JDK with GraalVM support.

To check whether you have a JDK with GraalVM support, execute the java -version command in your terminal.

java -version

If the output contains the following text, you have a JDK with GraalVM support installed:

GraalVM

If not, you can install one by following the instructions in the Install GraalVM section of the GraalVM documentation or by using the SDKMAN tool.

Compilation Steps

To compile your Vaadin application into a native image, follow these steps:

  1. Compile your application using Maven by executing the following command in the project root directory:

    mvn -Pproduction -Pnative native:compile

    This command compiles your application with the production and native profiles enabled. The native profile instructs Maven to use the GraalVM native image compiler for the compilation process.

  2. Run the application. The compilation creates the native image in the target directory. To run the application, execute the following command:

    ./target/<app-name>

    Your Vaadin application is now running as a native image, benefiting from faster startup times and lower memory consumption.

More Resources

For more information on native image compilation and instructions on creating Docker images using build packs, see the Spring Boot Reference Guide.