Kotlin application that generates a cross-platform native executable using GraalVM
- Linux X 64
- MacOS X 64
- Ming X 64
Running the native executable does not require any dependencies or installations. The generated binary contains all the dependencies it needs within itself. As a result, you can execute the binary just from the bash or the shell without having anything else installed - not even JRE!
# Usage (Linux & Mac)
$ ./cli-executable
# Usage (Windows)
$ .\cli-executable
You are required to do this only if you wish to view/modify the source of the application and build and package it again.
- JDK ==> 8
- Gradle ==> 6.8
- Kotlin ==> 1.5.21
- GraalVM / Native Image ==> 20.0.0
Ensure that your system-level JDK is pointing to GraalVM. Verify this by doing java -version
# Clone the repo
$ git clone [email protected]:abbasdgr8/graal-kotlin-starter.git
# Change into the directory
$ cd graal-native-executable
# Initiate the gradle build
$ ./gradlew clean build
# Build cross-platform executable from generated jar
$ $GRAALVM_HOME/bin/native-image --report-unsupported-elements-at-runtime -jar build/libs/graal-native-executable-1.0-SNAPSHOT.jar cli-executable --enable-url-protocols=http --no-server
If you plan to add Java Reflection based libraries to this application, they may not play well with GraalVM.