How to install GraalVM and native-image on Ubuntu

Dmytro Chaban
Apr 19, 2020 · 3 min read
Image for post
Image for post

In this guide, you gonna see how easy it is to install GraalVM on Ubuntu Linux and start using awesome features like cross-language communication, faster JVM and more.

For better command copy-paste experience, please open this article on quarkify.

Before we start

We need to ensure that we have all the required technologies available on PC to use native-image, don't forget to click Y when prompted.

GraalVM installation

Once it’s done, we’re ready to load and install GraalVM instance. First of all, we need to load it onto our machine. You can find latest GraalVM versions on official GitHub. First of all, you can choose to use either Java11 or Java8. For Java11, there’s also different archetypes: depending on your machine version, it can be either ...-linux-aarch64-version.tar.gz or ...-linux-amd64-version.tar.gz. This tutorial goes with java8-linux-amd64-20.0.0, let's load it and unzip:

Once it’s done, you can find new folder called graalvm-ce-java8–20.0.0, or similar. This folder contains all the binaries required to use GraalVM, as well as JDK to run our Java apps. Now, we need to copy it over to place where we can use it for both purposes.

Specify PATH and JAVA_HOME

Okay, now that our GraalVM is in a handy place, the last thing that is left is to tell our system that you have it on the machine and you would like to access it via command line:

Now, once you restart or re-login into your machine, you’ll have java and gu utils available for use. To start using them without restart you’ll need to execute source command:

Now, you should be able to use any of the commands that GraalVM has to offer:

Native-image installation

This part is a lot easier and faster than GraalVM installation, this is because Graal comes with Graal Updater, or gu for short. gu command allows you to install any additional dependencies. To install native-image you just need to run next command:

(Optional) Install more features

While we’re at it, you may have the target to use additional features that are not available out of the box. This can be accomplished again with gu command. You can run gu available to look at all available options.

We’re gonna install Python, but you can use any, procedure is the same for all of them

Verify installation

Let’s create super simple java example: use any editor that you’re comfortable with(vim, nano, emacs, idea) to create a

Save the file, now let’s ensure that our normal GraalVM java is working, that’s easy as running next lines of code:

Building a native image

To build a native image you only need additional command to code above. Just run native-image on compiled java file.

It will take some time, once it’s done, you’ll have lowercased helloworld file that you can execute without any other tool.

That’s it, now you’re ready to start building native applications with Quarkus.

Let me know how much advantage GraalVM gave you, maybe your startup time became 10x faster, or maybe now you can call other languages from Java to solve some real-world problems. Please let me know in a comments 🙂

Originally published at on April 19, 2020.


Latest Quarkus Articles, Tutorials and News

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store