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

Generated by publish_docs from dist/markdown/html/src/docs/common_tasks/jvm_options.html 2017-10-20T21:24:32.547083