By Alvin Alexander. Last updated: January 19, 2020
Scala FAQ: How do I set Java and JVM command-line arguments when running a Scala application?
To set Java/JVM command line arguments when running a Scala application with the scala
command, set the JAVA_OPTS
environment variable before running your application, something like this:
$ JAVA_OPTS="-Xmx256m -Xms64m -Xss16M" $ scala my_scala_app.jar
I found this information on this scala man page document, where they also state this about the JAVA_OPTS
variable:
Specify the options to be passed to the java command defined by JAVACMD. With Java 1.5 (or newer) one may for example configure the memory usage of the JVM as follows: JAVA_OPTS="-Xmx512M -Xms16M -Xss16M" With GNU Java one may configure the memory usage of the GIJ as follows: JAVA_OPTS="--mx512m --ms16m"