Passing JVM flags to bazel run target

5,101 views
Skip to first unread message

mvn...@gmail.com

unread,
Aug 12, 2016, 1:42:34 PM8/12/16
to bazel-discuss
I can't seem to find the right incantation to pass some JVM flags to a bazel run target. I've tried "--jvm_flag" and "-jvmopt" both before and after the bazel run command. For example:

bazel run -- //:target -Dflag=value
bazel run --jvmopt="-Dflag=value" -- //:target
bazel run -- //:target --jvm_flag="-Dflag=value"

But, none of these seem to work. Is there some way to pass jvm flags to the java_binary through bazel run?

dkon...@gmail.com

unread,
Jan 9, 2017, 1:41:35 AM1/9/17
to bazel-discuss, mvn...@gmail.com
Came across this while searching for a similar question. Here's the answer:

bazel run //<target> --jvmopt="-Xdebug" --jvmopt="-Xmx:512m" --jvmopt="-Xms:512m"
etc

Doug Tangren

unread,
May 26, 2017, 1:01:39 AM5/26/17
to bazel-discuss, mvn...@gmail.com, dkon...@gmail.com


On Monday, January 9, 2017 at 1:41:35 AM UTC-5, dkon...@gmail.com wrote:
Came across this while searching for a similar question. Here's the answer:

bazel run //<target> --jvmopt="-Xdebug" --jvmopt="-Xmx:512m" --jvmopt="-Xms:512m"


This doesn't seem to work for system properties. Should it?

Andrew Barchuk

unread,
Jun 5, 2017, 11:59:00 AM6/5/17
to Doug Tangren, bazel-discuss, mvn...@gmail.com, dkon...@gmail.com
Hi Doug,

Late for the party but the following works to set system properties:

bazel run --jvmopt='-Dprop1=val1 -Dprop2=val2' :binary <args>

Hope it would be useful for someone.

---
Andrew

Hoa Phan

unread,
Nov 21, 2018, 10:25:16 PM11/21/18
to bazel-discuss
Does it still work for you, I just tried

bazel run --jvmopt='-verbose' :binary <args> 

But it seems the verbose flag was not passed along. I'm on Bazel 0.18.
Reply all
Reply to author
Forward
0 new messages