GraalVM Native Image (https://www.graalvm.org/native-image/)
This tool can ahead-of-time compile Java code to native executables.
Usage: native-image [options] class [imagename] [options]
(to build an image for a class)
or native-image [options] -jar jarfile [imagename] [options]
(to build an image for a jar file)
or native-image [options] -m <module>[/<mainclass>] [options]
native-image [options] --module <module>[/<mainclass>] [options]
(to build an image for a module)
where options include:
@argument files one or more argument files containing options
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
--class-path <class search path of directories and zip/jar files>
A : separated list of directories, JAR archives,
and ZIP archives to search for class files.
-p <module path>
--module-path <module path>...
A : separated list of directories, each directory
is a directory of modules.
--add-modules <module name>[,<module name>...]
root modules to resolve in addition to the initial module.
<module name> can also be ALL-DEFAULT, ALL-SYSTEM,
ALL-MODULE-PATH.
-D<name>=<value> set a system property
-J<flag> pass <flag> directly to the JVM running the image generator
--diagnostics-mode enable diagnostics output: class initialization, substitutions, etc.
--enable-preview allow classes to depend on preview features of this release
--enable-native-access <module name>[,<module name>...]
modules that are permitted to perform restricted native operations.
<module name> can also be ALL-UNNAMED.
--verbose enable verbose output
--version print product version and exit
--help print this help message
--help-extra print help on non-standard options
--auto-fallback build stand-alone image if possible
--color color build output ('always', 'never', or 'auto')
--enable-all-security-services
add all security service classes to the generated image.
--enable-http enable http support in the generated image
--enable-https enable https support in the generated image
--enable-monitoring enable monitoring features that allow the VM to be inspected at
run time. Comma-separated list can contain 'heapdump', 'jfr',
'jvmstat', 'jmxserver' (experimental), 'jmxclient'
(experimental), 'threaddump', 'nmt' (experimental), or 'all'
(deprecated behavior: defaults to 'all' if no argument is
provided). For example: '--enable-monitoring=heapdump,jfr'.
--enable-url-protocols
list of comma separated URL protocols to enable.
--exact-reachability-metadata
enables exact and user-friendly handling of reflection, resources,
JNI, and serialization.
--exact-reachability-metadata-path
trigger exact handling of reflection, resources, JNI, and
serialization from all types in the given class-path or
module-path entries.
--features a comma-separated list of fully qualified Feature implementation
classes
--force-fallback force building of fallback image
--gc=<value> select native-image garbage collector implementation. Allowed
options for <value>:
'epsilon': Epsilon garbage collector
'serial': Serial garbage collector (default)
--initialize-at-build-time
a comma-separated list of packages and classes (and implicitly all
of their superclasses) that are initialized during image
generation. An empty string designates all packages.
--initialize-at-run-time
a comma-separated list of packages and classes (and implicitly all
of their subclasses) that must be initialized at runtime and not
during image building. An empty string is currently not
supported.
--install-exit-handlers
provide java.lang.Terminator exit handlers
--libc selects the libc implementation to use. Available implementations:
glibc, musl, bionic
--link-at-build-time require types to be fully defined at image build-time. If used
without args, all classes in scope of the option are required to
be fully defined.
--link-at-build-time-paths
require all types in given class or module-path entries to be
fully defined at image build-time.
--list-cpu-features show CPU features specific to the target platform and exit.
--list-modules list observable modules and exit.
--native-compiler-options
provide custom C compiler option used for query code compilation.
--native-compiler-path
provide custom path to C compiler used for query code compilation
and linking.
--native-image-info show native-toolchain information and image-build settings
--no-fallback build stand-alone image or report failure
--parallelism the maximum number of threads to use concurrently during native
image generation.
--shared build shared library
--silent silence build output
--static build statically linked executable (requires static libc and zlib)
--static-nolibc build statically linked executable with libc dynamically linked
--target selects native-image compilation target (in <OS>-<architecture>
format). Defaults to host's OS-architecture pair.
--trace-object-instantiation
comma-separated list of fully-qualified class names that object
instantiation is traced for.
-O control code optimizations: b - optimize for fastest build time, s
- optimize for size, 0 - no optimizations, 1 - basic
optimizations, 2 - advanced optimizations, 3 - all optimizations
for best performance.
-da also -da[:[packagename]...|:classname] or
-disableassertions[:[packagename]...|:classname]. Disable
assertions with specified granularity at run time.
-dsa also -disablesystemassertions. Disables assertions in all system
classes at run time.
-ea also -ea[:[packagename]...|:classname] or
-enableassertions[:[packagename]...|:classname]. Enable
assertions with specified granularity at run time.
-esa also -enablesystemassertions. Enables assertions in all system
classes at run time.
-g generate debugging information
-march generate instructions for a specific machine type. Defaults to
'x86-64-v3' on AMD64 and 'armv8-a' on AArch64. Use
-march=compatibility for best compatibility, or -march=native for
best performance if the native executable is deployed on the same
machine or on a machine with the same CPU features. To list all
available machine types, use -march=list.
-o name of the output file to be generated
Available macro-options are:
--language:icu4j
--language:js
--language:nfi
--language:nodejs
--language:regex
--language:truffle-json
--tool:chromeinspector
--tool:coverage
--tool:dap
--tool:insight
--tool:insightheap
--tool:lsp
--tool:profiler
Options (47)
| Option | Description | Source |
|---|---|---|
-D name>=<value | set a system property | help |
-J flag | pass <flag> directly to the JVM running the image generator | help |
--diagnostics-mode | enable diagnostics output: class initialization, substitutions, etc. | help |
--enable-preview | allow classes to depend on preview features of this release | help |
--verbose | enable verbose output | help |
--version | print product version and exit | help |
--help | print this help message | help |
--help-extra | print help on non-standard options | help |
--auto-fallback | build stand-alone image if possible | help |
--color | color build output ('always', 'never', or 'auto') | help |
--enable-all-security-services | add all security service classes to the generated image. | help |
--enable-http | enable http support in the generated image | help |
--enable-https | enable https support in the generated image | help |
--enable-monitoring | enable monitoring features that allow the VM to be inspected at run time. | help |
--enable-url-protocols | list of comma separated URL protocols to enable. | help |
--exact-reachability-metadata | enables exact and user-friendly handling of reflection, resources, JNI, and serialization. | help |
--exact-reachability-metadata-path | trigger exact handling of reflection, resources, JNI, and serialization from all types in the given class-path or module-path entries. | help |
--features | a comma-separated list of fully qualified Feature implementation classes | help |
--force-fallback | force building of fallback image | help |
--gc value | select native-image garbage collector implementation. | help |
--initialize-at-build-time | a comma-separated list of packages and classes (and implicitly all of their superclasses) that are initialized during image generation. | help |
--initialize-at-run-time | a comma-separated list of packages and classes (and implicitly all of their subclasses) that must be initialized at runtime and not during image building. | help |
--install-exit-handlers | provide java.lang.Terminator exit handlers | help |
--libc | selects the libc implementation to use. | help |
--link-at-build-time | require types to be fully defined at image build-time. | help |
--link-at-build-time-paths | require all types in given class or module-path entries to be fully defined at image build-time. | help |
--list-cpu-features | show CPU features specific to the target platform and exit. | help |
--list-modules | list observable modules and exit. | help |
--native-compiler-options | provide custom C compiler option used for query code compilation. | help |
--native-compiler-path | provide custom path to C compiler used for query code compilation and linking. | help |
--native-image-info | show native-toolchain information and image-build settings | help |
--no-fallback | build stand-alone image or report failure | help |
--parallelism | the maximum number of threads to use concurrently during native image generation. | help |
--shared | build shared library | help |
--silent | silence build output | help |
--static | build statically linked executable (requires static libc and zlib) | help |
--static-nolibc | build statically linked executable with libc dynamically linked | help |
--target | selects native-image compilation target (in <OS>-<architecture> format). | help |
--trace-object-instantiation | comma-separated list of fully-qualified class names that object instantiation is traced for. | help |
-O | control code optimizations: b - optimize for fastest build time, s | help |
-da | also -da[:[packagename]...|:classname] or | help |
-dsa | also -disablesystemassertions. | help |
-ea | also -ea[:[packagename]...|:classname] or | help |
-esa | also -enablesystemassertions. | help |
-g | generate debugging information | help |
-march | generate instructions for a specific machine type. | help |
-o | name of the output file to be generated | help |