Building Quarkus native applications with Mandrel

Mandrel is a downstream open source distribution of GraalVM edition which can be used to create native builds for Quarkus applications. Quarkus applications require one essential tool of GraalVM – the native-image feature – which is what actually produces native executables. Mandrel let us to have GraalVM bundled on top of OpenJDK 11 in RHEL distributions and other OpenJDK 11 distributions. Thus, Mandrel can best be described as a distribution of a regular OpenJDK with a specially packaged GraalVM native image.

Mandrel releases are built from the upstream GraalVM code base, with just a few minor changes. Mandrel supports the same native image capability as GraalVM with no significant changes to functionality. One minor difference is that Mandrel does not include support for Polyglot programming languages via the Truffle interpreter and compiler framework. Therefore, it is not possible to extend Mandrel by downloading languages from the Truffle language catalogue.

Mandrel is also built using the standard OpenJDK project release of jdk11u, therefore it does not include a few small enhancements added by Oracle to the JVMCI module which allows the Graal compiler to be run inside OpenJDK.

That being said, these differences should not cause the resulting images themselves to execute in a noticeably different manner.

Installing Mandrel

In order to install, you need at first to install the following packages which are required for Mandrel’s native-image tool:

On Fedora/CentOS/RHEL machines:

sudo dnf install glibc-devel zlib-devel gcc libffi-devel

On Ubuntu systems with:

sudo apt install gcc zlib1g-dev libffi-dev

Then, download the latest release of Mandrel from:

In our case, we will download mandrel-java11-linux-amd64-

quarkus mandrel tutorial quarkus

Then, untar the distribution:

$ tar -xf mandrel-java11-linux-amd64-

The folder mandrelJDK will be created as top JDK directory:

$ ls mandrelJDK
bin  conf  demo  include  jmods  languages  legal  lib  LICENSE  man  release  THIRD_PARTY_LICENSE.txt

Now you need to set up the JAVA_HOME, GRAALVM_HOME and PATH to include the folder mandrelJDK:

$ export JAVA_HOME="$( pwd )/mandrelJDK"
$ export PATH="${JAVA_HOME}/bin:${PATH}"

Check that your Java version is built on the top of OpenJDK 11.08:

java -version
openjdk version "11.0.8-ea" 2020-07-14
OpenJDK Runtime Environment 18.9 (build 11.0.8-ea+7)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.8-ea+7, mixed mode)

Building a Quarkus native application with Mandrel

Now you can try to build a sample Quarkus application as native executable:

$ curl -O -J
$ unzip
$ cd code-with-quarkus/
$ ./mvnw package -Pnative
$ ./target/code-with-quarkus-1.0.0-SNAPSHOT-runner

The following output will be displayed:

__  ____  __  _____   ___  __ ____  ______ 
 --/ __ \/ / / / _ | / _ \/ //_/ / / / __/ 
 -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \   
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/   
2020-07-11 18:45:40,939 INFO  [io.quarkus] (main) code-with-quarkus 1.0.0-SNAPSHOT native (powered by Quarkus 1.6.0.Final) started in 0.012s. Listening on:
2020-07-11 18:45:40,939 INFO  [io.quarkus] (main) Profile prod activated. 
2020-07-11 18:45:40,939 INFO  [io.quarkus] (main) Installed features: [cdi, resteasy]

Check that the “hello” Endpoint:

$ curl http://localhost:8080/hello

Great. You just managed to build your native executable application using Quarkus and Mandrel distribution.