How to pass system properites in comand line to scala 3 executable

40 Views Asked by At

With scala 2 it was possible to pass system properties in the command line using -D<propname>=<propvalue> like in the following example:

$scala -Dpath.to.folder=/opt/myfolder

Scala v3 does not accept -D in the command line anymore:

$ scala -Dpath.to.folder=/opt/myfolder
bad option '-Dpath.to.folder=/opt/myfolder' was ignored
Welcome to Scala 3.1.0 (11.0.9.1, Java OpenJDK 64-Bit Server VM).

One possible solution (workaround) is to pass the properties through the environment:

$ env SYS_PROPS="-Dpath.to.folder=/opt/myfolder" scala
Welcome to Scala 3.1.0 (11.0.9.1, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.

scala> println(System.getenv().get("SYS_PROPS"))
-Dpath.to.folder=/opt/myfolder

scala>

How is it possible to pass system properties in the command line of scala 3 executables? scala --help does not provide any useful info. Actually in scala 3.1.0 scala --help and scalac --help print the same message in the stdout.

0

There are 0 best solutions below