You need to first install GraalVM, and then set your PATH so that you get the GraalVM binaries
Then you need the kotlin compiler toolchain. Easiest with sdkman Create a Kotlin file and add a simple program
$> cat src/main.kt
fun main() {
println("hello")
}
Emmit java byte code with kotlin. Do not forget to include the runtime but not the reflection library
kotlinc -include-runtime src/main.kt -d main.jar
Now run graal's aot compiler on the jvm byte code
$> native-image -cp main.jar MainKt
Build on Server(pid: 30544, port: 26682)
classlist: 318.36 ms
(cap): 1,866.47 ms
setup: 2,153.75 ms
(typeflow): 2,790.60 ms
(objects): 931.18 ms
(features): 26.37 ms
analysis: 3,813.06 ms
universe: 337.25 ms
(parse): 529.82 ms
(inline): 537.83 ms
(compile): 5,301.12 ms
compile: 6,606.64 ms
image: 509.38 ms
write: 558.19 ms
[total]: 14,337.96 ms
Finally run your native executable
$> ./mainKt
hello
You just compiled kotlin code to native.