Native Image Quick Reference
Build a native IMAGE Build an optimized Native Image Configure a Native Image
Build a native image from a JAR file with all dependencies: Build an image with profile-guided optimizations: Static analysis requires configuration for some language native-image [options] -jar myApp.jar native-image --pgo-instrument MyApp [imagename] features: accessing resources, serialization, reflection, JNI, Run the image to record the profile:./myapp etc. Specify classes search path for directories, JARs, ZIPs: native-image --pgo default.iprof MyApp -cp jar:com/package/**/myApp.jar Select GraalVM’s garbage collector implementation: Run a Java process with tracing agent to generate the configuration: Specify the custom main class: --gc=G1 java -agentlib:native-image-agent= -H:Class=MyApp config-output-dir=/path/to/config-dir/ Control classes initialization at build or run time: Build a shared library -jar MyApp.jar --initialize-at-build/run-time= Specify the configuration to use for building a native image: native-image -jar jarfile [libraryname] com.example.MyClass,org.package -H:ConfigurationFileDirectories=/path/to/ --shared Include resources matching Java RegEx: config-dir/ -H:IncludeResource=/com/package/**/file.xml
Enable HTTPS support: Annotate the entry point method(s) with the Configuration files in META-INF/native-image on the classpath are included automatically. --enable-https @CEntryPoint annotation. Entry point methods must be static, have non-object parameters and return types. Install exit handlers: Configure memory at run time: --install-exit-handlers ./imagename -Xmx