Converting your CLI to a native application

It is also possible to compile your Agent SDK application to a native executable. To get started, you will need to ensure that you have GraalVM installed and configured by downloading the GraalVM at https://www.graalvm.org/downloads/arrow-up-right. GraalVM 24 is the preferred version.

Once you have GraalVM installed, you need to update your build.xml for your project to mirror the following:

plugins {
    id 'java'
    id "io.freefair.lombok" version "8.6"
    id("org.springframework.boot") version "3.5.3"
    id 'org.graalvm.buildtools.native' version '0.10.6'
}

You may also want to disable most logging in this mode. You can do that by adding the following to application.properties:

logging.level.root = OFF

Now, you just need to tell Gradle to build the native image.

circle-info

Remember, you need to set GraalVM as your default Java VM first - this includes setting the JAVA_HOME environment variable!

./gradlew nativeCompile

You'll see some output as it compiles that looks like the following:

========================================================================================================================
GraalVM Native Image: Generating 'agent-sdk-sample' (executable)...
========================================================================================================================
For detailed information and explanations on the build output, visit:
https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/BuildOutput.md
------------------------------------------------------------------------------------------------------------------------

After a bit, you'll see it successfully complete and you'll have a native executable! Now we can run:

That's it!

Last updated

Was this helpful?