Skip to main content

Packaging Scala applications as GraalVM native images

Scala CLI lets you package your applications as native executables using GraalVM native images.

As an example, let's package the following application as a native executable using GraalVM native image:

object Echo {
def main(args: Array[String]): Unit =
println(args.mkString(" "))

The following command packages this application as a native executable:

scala-cli --power package --native-image Echo.scala -o echo
# Run echo on macOS
./echo a b
# a b

You can pass custom options to GraalVM native image by passing them after --, like

scala-cli --power package --native-image Echo.scala -o echo -- --no-fallback