- Latest (GraalVM for JDK 21)
- Dev Build
- GraalVM for JDK 21
- GraalVM for JDK 20
- GraalVM for JDK 17
- GraalVM 22.3
- GraalVM 22.2
- GraalVM 22.1
- GraalVM 22.0
- GraalVM 21.3
- Getting Started with Native Image
- Native Image Basics
- Build Overview
- Build Output
- Build Configuration
- Native Image Bundles
- Build Options
- Hosted and Runtime Options
- Reachability Metadata
- Optimizations and Performance
- Debugging and Diagnostics
- Dynamic Features
- Interoperability with Native Code
- LLVM Backend
- Workshops and Labs
Native Image Build Overview
The syntax of the
native-image command is:
native-image [options] <mainclass> [imagename] [options]to build a native binary from
<mainclass>class in the current working directory. The classpath may optionally be provided with the
-cp <classpath>option where
<classpath>is a colon-separated (on Windows, semicolon-separated) list of paths to directories and jars.
native-image [options] -jar jarfile [imagename] [options]to build native binary from a JAR file.
native-image [options] -m <module>/<mainClass> [imagename] [options]to build a native binary from a Java module.
The options passed to
native-image are evaluated from left to right.
The options fall into three categories:
- Image generation options - for the full list, run
- Macro options
- Non-standard options - subject to change through a deprecation cycle, run
native-image --help-extrafor the full list.
Find a complete list of options for the
native-image tool here.
There are some expert level options that a Native Image developer may find useful or needed, for example, the option to dump graphs of the
native-image builder or enable assertions at image run time. This information can be found in Native Image Hosted and Runtime Options.
Further Reading #
If you are new to GraalVM Native Image or have little experience using it, see the Native Image Basics to better understand some key aspects before going further.
For more tweaks and how to properly configure the
native-image tool, see Build Configuration.
Native Image will output the progress and various statistics when building the native binary. To learn more about the output, and the different build phases, see Build Output.