• Stars
    star
    544
  • Rank 81,699 (Top 2 %)
  • Language
    Java
  • License
    Universal Permiss...
  • Created over 6 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

This repository contains example applications to illustrate the different capabilities of GraalVM

GraalVM Demos

This repository contains demo applications and benchmarks written in Java, JavaScript, Python, R, Ruby, and other JVM languages such as Kotlin and Scala. These applications illustrate the diverse capabilities of GraalVM.

The demos are sorted by a framework, by a programming language, or by a technology. Each directory contains demo sources; the instructions on how to run a particular demo are in its README.md file. To get started, clone or download this repository, enter the demo directory, and follow steps in the README.md file.

git clone https://github.com/graalvm/graalvm-demos.git
cd graalvm-demos

GraalVM JDK and Native Image

Name Description
tiny-java-containers
tiny-java-containers
Demonstrates how to build very small Docker container images with GraalVM Native Image and various lightweight base images.
Technologies: Native Image, musl libc
Reference: Static and Mostly Static Images
hello-graal
hello-graal
Demonstrates how to build native executables from a class file and a JAR file from the command line
Technologies: Native Image
Reference: Native Image Getting Started
java-hello-world-maven
java-hello-world-maven
Demonstrates how to generate a native executable using the Native Build Tools Maven plugin
Technologies: Native Image, Native Build Tools Maven plugin
Reference: GraalVM Enterprise in OCI Code Editor
native-hello-module
native-hello-module
Demonstrates how to build a modular Java application into a native executable
Technologies: Native Image, Maven
Reference: Build Java Modules into a Native Executable
native-list-dir
native-list-dir
Demonstrates how to compile a CLI application into a native executable. The second part demonstrates how to build a polyglot (Java and JS) native executable.
Technologies: Native Image, JavaScript
Reference: Ahead-of-Time Compilation of Java and Polyglot Applications
java-simple-stream-benchmark
java-simple-stream-benchmark
Demonstrates how the Graal compiler can achieve better performance for highly abstracted programs like those using Streams, Lambdas
Technologies: Graal compiler, C2
Reference: Simple Java Stream Benchmark
streams
streams
Demontrates how GraalVM efficiently optimizes the Java Streams API application and how to apply PGO
Technologies: Native Image, Native Build Tools Maven Plugin
Reference: Optimize a Native Executable with Profile-Guided Optimizations
fortune-demo
fortune-demo
A fortune teller Unix program. Run it in JIT, build a native executable, or build a mostly-static native executable, using Gradle or Maven build tools.
Technologies: Native Image, Native Build Tools
Reference: Use GraalVM Dashboard to Optimize the Size of a Native Executable
multithreading-demo
streams
Demonstrates how to optimize a Java application that does synchronous and asynchronous threads execution
Technologies: Native Image, Native Build Tools Maven Plugin, GraalVM Dashboard
Reference: Making sense of Native Image contents
native-image-configure-examples
streams
Demonstrates how you can influence the classes initialization at the image build time
Technologies: Native Image, Maven
Reference: Understanding Class Initialization in GraalVM Native Image Generation
native-netty-plot
native-netty-plot
A web server application, using the Netty framework, to demonstrate the use of isolates with Native Image
Technologies: Native Image, Maven, Netty
Reference: Instant Netty Startup using GraalVM Native Image Generation
javagdbnative
javagdbnative
Demonstrates how to debug a Java application, built into a native executable in VS Code
Technologies: Native Image, Maven, GraalVM Tools for Java
Reference: Native Image Debugging in VS Code
native-image-logging-examples
native-image-logging-examples
This demo demonstrates how you can initialize Loggers with Native Image at the executable build or run time
Technologies: Native Image
Reference: Add Logging to a Native Executable
native-jfr-demo
native-jfr-demo
Demonstrates how to create a custom JDK Flight Recorder (JFR) event and use that in a native executable
Technologies: Native Image, JFR, VisualVM
Reference: Build and Run Native Executables with JFR
native-shared-library
native-shared-library
This demo shows how to create a Java class library, use Native Image to create a native shared library, and then create a small C application that uses that shared library
Technologies: Native Image, LLVM toolchain
Reference: Build a Native Shared Library
native-image-reflection-example
native-image-reflection-example
The following application demonstrates the use of Java reflection and how to provide metadata for Native Image using a JSON configuration file.
Technologies: Native Image
native-static-images
native-static-images
This demo demonstrates how to build a fully static and mostly-static native executable.
Technologies: Native Image
Reference: Build a Statically Linked or Mostly-Statically Linked Native Executable
native-heapdump-examples
native-heapdump-examples
This demo shows how you can create a heap dump of a running native executable.
Technologies: Native Image, VisualVM
Reference: Create a Heap Dump from a Native Executable
native-image-jmx-demo
nnative-image-jmx-demo
This demo covers the steps required to build, run, and interact with a native executable using JMX.
Technologies: Native Image, JMX, VisualVM
Reference: Build and Run Native Executables with Remote JMX

Native Image on Cloud Platforms

Name Description
native-aws-fargate
native-aws-fargate
This demo covers the steps required to create a container image of a native executable application and deploy the image on AWS Fargate.
Technologies: Native Image, Apache Maven, Docker, AWS Fargate
native-aws-lambda
native-aws-lambda
This demo covers the steps required to deploy a native executable application on AWS Lambda.
Technologies: Native Image, Apache Maven, Docker, AWS Lambda
native-google-cloud-run
native-google-cloud-run
This demo covers the steps required to create a container image of a native executable application and deploy the image on Google Cloud Run.
Technologies: Native Image, Apache Maven, Docker, Google Cloud CLI, Google Cloud Run
native-oci-container-instances
native-oci-container-instances
This demo covers the steps required to create a container image of a native executable application and deploy the image on OCI Container Instances.
Technologies: Native Image, Apache Maven, Docker, OCI Container Instances

Java on Truffle (Espresso)

Name Description
espresso-jshell
espresso-jshell
Demonstrates how to build a native executable of JShell, that executes the dynamically generated bytecodes on Espresso
Technologies: Java on Truffle, Native Image, JShell
Reference: Mixing AOT and JIT for Java, Java on Truffle — Going Fully Metacircular

Micronaut

Name Description
micronaut-hello-rest-maven
micronaut-hello-rest-maven
Demonstrates how to package a Micronaut REST application into a native executable with Native Image Maven plugin
Technologies: Native Image, Micronaut, Native Build Tools Maven Plugin
Reference: Try in OCI Code Editor

Spring Boot

Name Description
spring-native-image
spring-native-image
Demonstrates how to turn a Spring Boot application into a native executable using Spring Native support
Technologies: Spring Boot, Spring Native, Native Image
Reference: GraalVM Native Image, Spring and Containerisation, GraalVM Enterprise in OCI Cloud Shell
spring-r
spring-r
Demonstrates GraalVM's polyglot feature by loading an R script into a Java host application
Technologies: Spring, FastR
Reference: Enhance your Java Spring application with R data science

Helidon

Name Description
js-java-async-helidon
js-java-async-helidon
An HTTP web service that demonstrates how multiple JavaScript contexts can be executed in parallel to handle asynchronous operations with Helidon in Java
Technologies: Native Image, Helidon
Reference: Asynchronous Polyglot Programming in GraalVM Using Helidon and JavaScript

Scala

Name Description
scalac-native Demonstrates how to build a native executable of the Scala compiler. The resulting binary has no dependencies on the JDK.
Technologies: Scala 2.12.x, Native Image
Reference: Compiling Scala Faster with GraalVM

Kotlin

Name Description
java-kotlin-aot
java-kotlin-aot
Demonstrates how to interoperate between Java and Kotlin and build a native executable
Technologies: Native Image, Kotlin, Maven

Python

Name Description
graalpy-notebook-example
graalpy-notebook-example
Demonstrates how to embed Python in a Java application running on GraalVM
Technologies: GraalPy

Polyglot

Name Description
polyglot-chat-app
polyglot-chat-app
Demonstrates how to build a polyglot chat application by embedding Python and R into the Java host language
Technologies: Java, GraalPy, FastR, Micronaut
polyglot-debug
polyglot-debug
Demonstrates how to debug a polyglot Java and JavaScript application using GraalVM extensions for VS Code
Technologies: Java, JavaScript, Maven, GraalVM Extension Pack
polyglot-javascript-java-r
polyglot-javascript-java-r
Demonstrates the polyglot capabilities of GraalVM and how to run a JavaScript-Java-R application
Technologies: JavaScript, Node.js, Java, R
Reference: Top 10 Things To Do With GraalVM
functionGraphDemo
functionGraphDemo
Demonstrates how to run a polyglot JavaScript-Java-R application on GraalVM Node.js runtime
Technologies: JavaScript, Node.js, Java, R

Compatibility

The demos are normal applications and benchmarks written in Java, JavaScript, Python, etc., so they are compatible with any virtual machine capable of running Java, JavaScript and so on. These demos are tested against the latest GraalVM release using GitHub Actions. If you come accross an issue, please submit it here.

License

Unless specified otherwise, all code in this repository is licensed under the Universal Permissive License (UPL). Note that the submodule fastR-examples which is a reference to the graalvm/examples repository has a separate license.

Learn More

More Repositories

1

graalvm-ce-builds

GraalVM CE binaires built by the GraalVM community
1,552
star
2

sulong

Obsolete repository. Moved to oracle/graal.
Java
628
star
3

simplelanguage

A simple example language built using the Truffle API.
Java
597
star
4

native-build-tools

Native-image plugins for various build tools
Java
367
star
5

graalvm-ten-things

Top 10 Things To Do With GraalVM
C
232
star
6

homebrew-tap

Ruby
207
star
7

setup-graalvm

GitHub Action for setting up GraalVM distributions.
TypeScript
190
star
8

mx

Command-line tool used for the development of Graal projects.
Python
179
star
9

graal-js-jdk11-maven-demo

An example project how to run Graal/JavaScript on JDK 11 with Graal as optimizing JIT compiler for best performance.
Java
175
star
10

container

GraalVM container images
166
star
11

graalvm-ce-dev-builds

GraalVM Dev Build Downloads
95
star
12

graal-jvmci-8

Fork of jdk8u/hotspot with support for JVMCI
C++
71
star
13

examples

Java
57
star
14

labs-openjdk-11

Based on jdk11u-dev with included support for libgraal and GraalVM CE.
Java
45
star
15

vscode-extensions

TypeScript
30
star
16

simpletool

A simple example tool built using the Truffle instrumentation API.
Java
28
star
17

openjdk8-jvmci-builder

Travis based builder for JVMCI JDK8 binaries based on OpenJDK8
26
star
18

graal-js-archetype

Java
24
star
19

workshops

A collection of workshops and live labs about GraalVM
Java
24
star
20

labs-openjdk-17

Based on JDK 17 with included support for libgraal and GraalVM CE.
Java
23
star
21

polyglot-embedding-demo

Demonstration repository showing polyglot embedding with GraalVM for JDK 21 using Maven and Gradle.
C
18
star
22

taming-build-time-initialization

Demos for the build-time initialization blog post
Java
17
star
23

mysql-mle-demos

Demos for the MySQL Multi-Lingual Environment
16
star
24

oracle-graalvm-ea-builds

Oracle GraalVM early access builds
Python
14
star
25

graalvm-jdk-downloader

Download the GraalVM JDK with ease.
Shell
13
star
26

graalvm-website

GraalVM: Run Programs Faster Anywhere 🚀
HTML
8
star
27

graal-js-jdk11-gradle-demo

An example project how to run Graal/JavaScript on JDK 11 with Graal as optimizing JIT compiler for best performance.
Java
8
star
28

CLAMH

CLAMH (Cross-LAnguage Microbenchmark Harness) is a language-independent benchmark harness design and the implementation of that design for different languages.
C++
7
star
29

mandrel-packaging

Java
6
star
30

graalvm.github.io

6
star
31

labs-openjdk-20

JDK 20 fork for building GraalVM CE.
Java
4
star
32

labs-openjdk-15

Based on jdk15u-dev with included support for libgraal and GraalVM CE.
Java
4
star
33

labs-openjdk

JDK fork for building GraalVM CE.
Java
4
star
34

graal-languages-ea-builds

Python
2
star
35

labs-openjdk-16

Based on JDK 16 with included support for libgraal and GraalVM CE.
Java
2
star
36

labs-openjdk-22

JDK 22 fork for building GraalVM CE.
Java
2
star
37

labs-openjdk-19

Based on JDK 19 with included support for libgraal and GraalVM CE.
Java
1
star