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:

Find a complete list of options for the native-image tool here.

Further Reading #

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.

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.

Connect with us