This is a small example how to build a CLI application which is compiled to a binary (no JVM startup delay!) via GraalVM (Substrate VM) while using useful libraries like decline, monix and better.files.
You need to have the GraalVM native-image
binary in your PATH
.
There are several ways to do this. I recommend to use sdkman.io and install 1.0-rc13
or newer
sdk install java 19.2.0-grl
# make sure ~/.sdkman/candidates/current/bin is in your PATH
gu install native-image
For normal development you can use sbt run
and related commands as usual.
Once you want to build your program into a binary, you run sbt show graalvm-native-image:packageBin
, which will
take some time and eventually show you the absolute path of your newly built executable binary.
I recommend building the binary once in a while (especially if you add new libaries), as some things are not supported
or need special native-image
flags. Saves time if you notice it early :)