You need to have a native-image
in your path.
The easiest way to get started is with SDKMan:
$ sdk install java 22.0.0.2.r17-nik
Once GraalVM is installed, you need to use it in your shell:
$ sdk use java 22.0.0.2.r17-nik
Validate that GraalVM is available in your shell:
$ java -version openjdk version "17.0.2" 2022-01-18 LTS OpenJDK Runtime Environment GraalVM 22.0.0.2 (build 17.0.2+9-LTS) OpenJDK 64-Bit Server VM GraalVM 22.0.0.2 (build 17.0.2+9-LTS, mixed mode, sharing)
The sample can be built with Maven or Gradle.
To build the project and generate a native image for it, run the following command:
$ ./mvnw package -Pnative
One the build has completed, the native executable is in your target
directory.
You can run it as follows:
$ target/demo-native-sample