Specify JVM Options
Problem
You need to specify command-line options for the JVM when running a Scala or Java goal, e.g. to set GC options, memory limits, enable debugging, etc.
Examples of JVM options can be found here.
Solution
Use the --jvm-run-jvm-options
flag to pass the options. Here's an example:
$ ./pants run my-jvm-project:bin --jvm-run-jvm-options='-XX:+UseParallelGC,-Xdebug,-Xprof'
As you can see in the example above, you can pass in multiple options separated by a comma. Multiple options can also be separated by line (just make sure not to use commas):
$ ./pants run my-jvm-project:bin --jvm-run-jvm-options=" -XX:+UseParallelGC -Xdebug -Xprof "
Discussion
The pants argument --jvm-run-jvm-options
is only used for arguments passed to the JVM itself, not to the executable target. If you need to pass command-line arguments to the executable target, see Pass Command-line Arguments to an Executable.
See Also
- Pass Command-line Arguments to an Executable
- Run a Binary Target
- Run JVM binaries and tests with different JVM versions
Generated by publish_docs
from dist/markdown/html/src/docs/common_tasks/jvm_options.html 2022-12-03T01:08:59.569939