Get Started with Oracle GraalVM Enterprise Edition

Here you will find information about downloading and installing GraalVM Enterprise, running basic applications with it, and adding support for its accompanying features. Further, you will learn about the polyglot capabilities of GraalVM Enterprise and see how to build platform-specific native executables of JVM-based applications.

If you are new to GraalVM Enterprise or have little experience using it, we recommend starting with the GraalVM Enterprise Overview page. There you will find information about GraalVM Enterprise’s architecture, the distributions available, supported platforms, licensing and support, core and additional features, and much more.

If you have GraalVM Enterprise already installed and have experience using it, you can skip this getting started guide and proceed to the in-depth Reference Manuals.

Download GraalVM Enterprise

You can get Oracle GraalVM Enterprise Edition by:

Install GraalVM Enterprise

Choose your operating system and proceed to the installation steps for your specific platform:

Running Applications

The core distribution of GraalVM includes the JVM and the GraalVM compiler. Having installed GraalVM, you can already run any Java application unmodified.

Other languages support can be installed on request, using gu – the GraalVM Updater tool to install additional language runtimes and utilities.

Runtime for Different Languages

Java

The java launcher runs the JVM with the GraalVM default compiler - Graal. Check the Java version upon the installation:

$JAVA_HOME/bin/java -version

Take a look at this typical HelloWorld class:

public class HelloWorld {
  public static void main(String[] args) {
    System.out.println("Hello, World!");
  }
}

Run the following commands to compile this class to bytecode and then execute it:

javac HelloWorld.java
java HelloWorld
Hello World!

You can find many larger Java examples among GraalVM Demos on GitHub. For more information on the GraalVM compiler, go to the Graal compiler. For more extensive documentation on running Java, proceed to JVM Languages.

JavaScript and Node.js

GraalVM supports running JavaScript applications. The JavaScript runtime is optionally available and can be installed with this command:

gu install js

It installs the js launcher in the $JAVA_HOME/bin directory. With the JavaScript runtime installed, you can execute plain JavaScript code, both in REPL mode and by executing script files directly:

$JAVA_HOME/bin/js
> 1 + 2
3

GraalVM also supports running Node.js applications. The Node.js support is not installed by default, but can be easily added with this command:

gu install nodejs

Both node and npm launchers then become available in the $JAVA_HOME/bin directory.

$JAVA_HOME/bin/node -v
$JAVA_HOME/bin/npm show <package name> version

More than 100,000 npm packages are regularly tested and are compatible with GraalVM Enterprise, including modules like express, react, async, request, browserify, grunt, mocha, and underscore. To install a Node.js module, use the npm executable from the <graalvm>/bin folder, which is installed together with node. The npm command is equivalent to the default Node.js command and supports all Node.js APIs.

Install the modules colors, ansispan, and express using npm install. After the modules are installed, you can use them from your application.

$JAVA_HOME/bin/npm install colors ansispan express

Use the following code snippet and save it as the app.js file in the same directory where you installed the Node.js modules:

const http = require("http");
const span = require("ansispan");
require("colors");

http.createServer(function (request, response) {
    response.writeHead(200, {"Content-Type": "text/html"});
    response.end(span("Hello Graal.js!".green));
}).listen(8000, function() { console.log("Graal.js server running at http://127.0.0.1:8000/".red); });

setTimeout(function() { console.log("DONE!"); process.exit(); }, 2000);

Run app.js on GraalVM Enterprise using the node command:

$JAVA_HOME/bin/node app.js

For more detailed documentation and information on compatibility with Node.js, proceed to JavaScript and Node.js.

LLVM Languages

The GraalVM LLVM runtime can execute C/C++, Rust, and other programming languages that can be compiled to LLVM bitcode.

The LLVM runtime is optionally available and can be installed with this command:

$JAVA_HOME/bin/gu install llvm

It installs the GraalVM implementation of lli in the $JAVA_HOME/bin directory. Check the version upon the installation:

$JAVA_HOME/bin/lli --version

With the LLVM runtime installed, you can execute programs in LLVM bitcode format on GraalVM. To compile a native program to LLVM bitcode, you use some LLVM frontend, for example clang.

Besides the LLVM runtime, GraalVM also provides the LLVM frontend (toolchain) that you can set up as follows:

gu install llvm-toolchain
export LLVM_TOOLCHAIN=$(lli --print-toolchain-path)

Then the C/C++ code can be compiled to LLVM bitcode using clang shipped with GraalVM. For example, put this C code into a file named hello.c:

#include <stdio.h>

int main() {
    printf("Hello from GraalVM!\n");
    return 0;
}

Compile hello.c to an executable hello with embedded LLVM bitcode and run it:

$LLVM_TOOLCHAIN/clang hello.c -o hello
lli hello

For in-depth documentation and more examples of running LLVM bitcode on GraalVM Enterprise, go to LLVM Languages.

Native Image

With GraalVM Enterprise you can compile Java bytecode into a platform-specific, self-contained, native executable to achieve faster startup and a smaller footprint for your application.

The Native Image functionality is not available by default, but can be easily installed with the GraalVM Updater tool:

gu install native-image

The HelloWorld example from above is used here to demonstrate how to generate a native executable:

public class HelloWorld {
  public static void main(String[] args) {
    System.out.println("Hello, World!");
  }
}

Note: For compilation native-image depends on the local toolchain. Make sure your system meets the prerequisites.

Compile HelloWorld.java to bytecode and then build a native executable:

javac HelloWorld.java
native-image HelloWorld

The last command generates an executable file named helloworld in the current working directory. Invoking it executes the natively compiled code of the HelloWorld class as follows:

./helloworld
Hello, World!

More detailed documentation on this innovative technology is available in the Native Image reference manual.

Combine Languages

GraalVM Enterprise allows you to call one programming language into another and exchange data between them. To enable interoperability, GraalVM Enterprise provides the --polyglot flag.

For example, running js --jvm --polyglot example.js executes example.js in a polyglot context. If the program calls any code in other supported languages, GraalVM Enterprise executes that code in the same runtime as the example.js application. For more information on running polyglot applications, see Polyglot Programming.

New Users

Since this guide is intended mainly for users new to GraalVM Enterprise, or users who are familiar with GraalVM Enterprise but may have little experience using it, consider investigating more complex Example Applications.

Oracle Cloud Users

Oracle Cloud users considering GraalVM Enterprise for their cloud workloads are invited to read GraalVM Enterprise on OCI. This page focuses on using GraalVM Enterprise with the Oracle Cloud Infrastructure Virtual Machine compute instance.

Advanced Users

If you are mostly interested in GraalVM Enterprise support for a specific language, or want more in-depth details about GraalVM Enterprise’s diverse features, proceed to Reference Manuals.

If you are looking for the tooling support GraalVM Enterprise offers, proceed to Debugging and Monitoring Tools.

If you are considering GraalVM Enterprise as a platform for your future language or tool implementation, go to GraalVM Enterprise as a Platform.

You can find information on GraalVM Enterprise’s security model in the Security Guide, and rich API documentation in GraalVM SDK Javadoc.