DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • ITBench, Part 1: Next-Gen Benchmarking for IT Automation Evaluation
  • How To Introduce a New API Quickly Using Quarkus and ChatGPT
  • Exploring Communication Strategies for LWC in Salesforce
  • Build a REST API With Just 2 Classes in Java and Quarkus

Trending

  • DZone's Article Submission Guidelines
  • The End of “Good Enough Agile”
  • MCP Servers: The Technical Debt That Is Coming
  • Rust, WASM, and Edge: Next-Level Performance
  1. DZone
  2. Coding
  3. Frameworks
  4. How to Use Native Image Kit With the Quarkus Framework

How to Use Native Image Kit With the Quarkus Framework

In this tutorial, learn how to use Liberica Native Image Kit, which is designed to support numerous platforms and programming languages, with Quarkus.

By 
Dmitry Chuyko user avatar
Dmitry Chuyko
·
Mar. 02, 22 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
3.5K Views

Join the DZone community and get the full member experience.

Join For Free

BellSoft issued a new version of Liberica Native Image Kit (NIK), 22.0.0.2, so in this short article, I will provide a tutorial on how to use it with the Quarkus framework.

Liberica NIK is based on the open-source project GraalVM (Community Edition) and is compatible with many platforms, including lightweight musl-based Alpine Linux. Liberica NIK in essence is a utility that converts JVM-based applications into native executables (AOT compilation).

The latest release of Liberica NIK 22.0.0.2 includes several enhancements: 

  • Added support for OpenJFX in Liberica NIK for macOS (Windows and Linux are already supported)
  • Native-image default inclusion in all NIK flavors. Running GU is no longer required for installation.

Why Would You Use Native Image?

Native image technology optimizes resource consumption, minimizes the static footprint, and delivers almost instant startup. Liberica NIK is designed to support a large number of platforms and programming languages, and therefore this kit provides an opportunity to create multilingual programs. The end result of utilizing Liberica NIK is cost reduction and accelerated deployment. 

How Can You Use Liberica NIK With the Quarkus Framework?

Quarkus is an open-source stack of technologies for the cloud-native world. While traditional Java stacks were made for monolithic applications, Quarkus is a new wave framework aiming to decrease large memory requirements in the industry where the cloud and containers play the leading role now. It is a Kubernetes-native Java framework and is tailored to the native images approach, perfect for deployment in the cloud and serverless development. Quarkus supports several popular standards of Jakarta EE/MicroProfile implementation. 

By using Liberica NIK with the Quarkus framework, you can actually boost its efficiency even more.

Let's Build a Native Image

So let's build a native image out of the Hello World application as an example, using Quarkus and Liberica NIK. To begin, you need to prepare all the necessary tools and software.

First, set up a working C compiler toolchain. On Linux, GCC and the glibc and zlib headers are necessary.

 
# dnf (rpm-based)

sudo dnf install gcc glibc-devel zlib-devel libstdc++-static

# Debian-based distributions:

sudo apt install build-essential libz-dev zlib1g-dev


On Windows, you will have to install the Visual Studio 2017 Visual C++ Build Tools.

In the case of MacOS, the dependencies are provided by XCode: xcode-select --install.

To demonstrate how to integrate Liberica NIK into Quarkus, we will use the basic Quarkus “Hello World” application. Go ahead and follow the instructions on the site to create a simple Quarkus app.

Now that you have your Hello World application ready, let’s configure the Native Image Kit.

Start with downloading the appropriate version of Liberica NIK (the package already contains Liberica VM and native-image tool). After the download is finished, check the file by verifying the checksum in the command line (the checksum should match the one next to the link on the downloads page).

Configure build environment. For Linux and macOS, in case you have TGZ/ZIP archive, set JAVA_HOME environment variable to the NIK installation directory:

export JAVA_HOME=$HOME/Development/bellsoft-liberica-vm-openjdk11-22.0.0.2  

If the installation is performed using the package (deb, pkg/dmg), the installation path for macOS will be the conventional one. 

On Windows, you will have to go through the Control Panel to set your environment variables.

Please note, that all releases of Liberica NIK starting from 21.3.1 include a native image by default, allowing you to skip the step of gu install. So I will not be describing this step here as it is not required in our process. 

If you followed the instructions and constructed the Quarkus application, you will find the following profile in the pom.xml:

 
<profiles>

    <profile>

        <id>native</id>

        <properties>

            <quarkus.package.type>native</quarkus.package.type>

        </properties>

    </profile>

</profiles>


The native executable for your application will contain the application code, necessary libraries, Java APIs, as well as a special reduced version of a virtual machine. To create it, run the following:

JAVA_HOME=$HOME/Development/bellsoft-liberica-vm-openjdk11-22.0.0.2./mvnw package -Pnative 

Note that it may take some time (several minutes usually) to package the native executable, so be patient. You also don’t need to prepend every command with setting JAVA_HOME if you export it as described in step 1.

Here we are! We have made a native executable for your application! Get the resulting executable file as target/getting-started-1.0.0-SNAPSHOT-runner.

To ensure everything works flawlessly, launch the application. 

If you have followed through this short exercise you are able to reach an incredible application start time of only 0.013 seconds with the latest Liberica Native Image Kit 22.0.0.2. Enjoy your development experience with this utility!

Quarkus Framework application Open source

Opinions expressed by DZone contributors are their own.

Related

  • ITBench, Part 1: Next-Gen Benchmarking for IT Automation Evaluation
  • How To Introduce a New API Quickly Using Quarkus and ChatGPT
  • Exploring Communication Strategies for LWC in Salesforce
  • Build a REST API With Just 2 Classes in Java and Quarkus

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!