Skip to content

felixbr/scala-cli-native-image-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scala CLI native-image example

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.

Prerequisites

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

Running and building the program

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 :)

About

Example of a Scala CLI app with no JVM startup delay

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages