native-image
high-performance JDK with ahead-of-time native compilation and polyglot support
TLDR
Compile Java to native executable
SYNOPSIS
native-image [options] class|-jar jarfile
gu command [options] [component]
js [options] [file]
graalpy [options] [file]
DESCRIPTION
GraalVM is a high-performance JDK with ahead-of-time native compilation and polyglot support. It runs Java, JavaScript, Python, Ruby, R, and LLVM-based languages.
native-image compiles Java applications to native executables. Benefits include instant startup, reduced memory, and no JVM dependency. Requires closed-world analysis—all code paths must be known at build time.
Reflection, dynamic proxies, and resources need configuration files. Use the tracing agent: java -agentlib:native-image-agent=config-output-dir=conf -jar app.jar to generate them.
gu (GraalVM Updater) manages optional components. Install language runtimes like Python (graalpy), Ruby (truffleruby), or LLVM toolchain.
GraalVM's Truffle framework enables high-performance language implementations. Languages can interoperate—call JavaScript from Java or vice versa.
NATIVE-IMAGE OPTIONS
-o name
Output file name.-jar file
Input JAR file.--no-fallback
Build native-only image (no JVM fallback).--static
Build fully static executable.-H:Name=name
Native image name.-H:+ReportExceptionStackTraces
Enable stack traces.--initialize-at-build-time
Initialize classes at build time.--initialize-at-run-time=classes
Initialize classes at runtime.-H:ReflectionConfigurationFiles=file
Reflection configuration.--diagnostics-mode
Generate diagnostic information.--verbose
Verbose output.
GU COMMANDS
install component
Install GraalVM component.remove component
Remove component.list
List installed components.available
List available components.update
Update installed components.rebuild-images
Rebuild native launchers.
CAVEATS
Native image build is resource-intensive. Some Java features require explicit configuration. Not all libraries support native compilation. Build time significantly longer than JVM startup.
HISTORY
GraalVM was developed at Oracle Labs, based on research into dynamic compilation. First released in 2018 as version 1.0. The Graal compiler originated from the Maxine VM project. GraalVM CE (Community Edition) is open source; Enterprise Edition adds optimizations. Native Image became production-ready in GraalVM 21. The project enables cloud-native Java with frameworks like Quarkus and Micronaut.
