scalascala-cli

Specify java version in scala-cli scala file


scala-cli can use a specific java version using --jvm adopt:11 cli option like:

scala-cli compile . --jvm adopt:11

There's a java-home directive in scala-cli that can be specified in a scala file.

e.g

// Test.scala
//> using java-home "/Users/Me/jdks/11"
//> using scala "3.2.0"

Is there a jvm directive that can be used to specify the JVM version directly in the scala file instead of scala-cli command option?

e.g

// Test.scala
//> using jvm "adopt:11" -- is there a way to do this?
//> using scala "3.2.0"

scala-cli --jvm option

scala-cli java-home directive


Solution

  • This feature is now included in scala-cli v0.1.17.

    https://github.com/VirtusLab/scala-cli/releases/tag/v0.1.17

    //> using jvm "adopt:11"