Command-line Options

Options to configure Native Image are provided in the following categories:

Depending on the GraalVM version, the options to the native-image builder may differ.

Native Image options can also be categorized as hosted or runtime options.

For more information describing how to define and use these options, read the com.oracle.svm.core.option package documentation.

Build Options

Run native-image --help for help on build options.

Extra Build Options

Run native-image --help-extra for help on additional options.

List of Useful Options

There are some expert level options that a user may find useful or needed. For example, the option to dump graphs of the native-image builder, or to print various statistics during the build process.

Build Output and Build Report

Native Image provides an informative build output including various statistics during the build process. The build output in a JSON-based, machine-readable format can be requested using the -H:BuildOutputJSONFile option, and later processed by a monitoring tool. The JSON files validate against the JSON schema defined in build-output-schema-v0.9.3.json. A comprehensive report with additional information can be requested using the --emit build-report option.

Note: The --emit build-report option is not available in GraalVM Community Edition.

Graph Dumping

Native Image re-used the options for graph dumping, logging, counters, and everything else from the GraalVM debug environment. These GraalVM options can be used both as hosted options (if you want to dump graphs of the native-image builder), and as runtime options (if you want to dump graphs during dynamic compilation at runtime).

The Graal compiler options that work as expected include Dump, DumpOnError, Log, MethodFilter, and the options to specify file names and ports for the dump handlers. For example:

System Properties

You can define system properties at image build time using the -D<system.property>=<value> option syntax. It sets a system property for the native-image tool, but the property will not be included in the generated executable. However, JDK system properties are included in generated executables and are visible at runtime.

For example:

The following system properties are automatically copied into the generated executable:

Name Description
file.separator File separator
file.encoding Character encoding for the default locale
java.version Java Runtime Environment version
java.version.date General-availability (GA) date of the release
java.class.version Java class format version number
java.runtime.version Java Runtime Environment version
java.specification.name Java Runtime Environment specification name
java.specification.vendor Java Runtime Environment specification vendor
java.specification.version Java Virtual Machine specification version
java.vm.specification.name Java Virtual Machine specification name
java.vm.specification.vendor Java Virtual Machine implementation vendor
java.vm.specification.version Java Virtual Machine specification version
line.separator Line separator
native.encoding Specifies the host environment’s character encoding
org.graalvm.nativeimage.kind Specifies if the image is built as a shared library or executable
path.separator Path separator
stdout.encoding Specifies the encoding for System.out and System.err
sun.jnu.encoding Specifies encoding when parsing values passed via the commandline