Java_opts in sbt

Gatling version: 3.11.3 (must be up to date)
Gatling flavor: scala
Gatling build tool: sbt

I read the guidelines and how to ask a question topics.
I provided a SSCCE (or at least, all information to help the community understand my topic)
I copied output I observe, and explain what I think should be.

Hi, I just discovered the magic of build tools (sbt in this case) and originally, I used to pass JAVA_OPTS to overwrite some script variables in old gatling bundle version as this command:

JAVA_OPTS="-Dparam=value" ./bin/ -s $SCALA_SCRIPT

Now when moving to sbt, I need to find a way to pass the JAVA_OPTS into sbt too, what I have tried so far (on gatling-sbt demo build.sbt)

val gatlingVersion : String = "3.11.3"
ThisBuild / scalaVersion := "2.13.14"

val value = sys.env.get("value")

fork := true
javaOptions ++= Seq(

libraryDependencies ++= Seq(
    "io.gatling.highcharts" % "gatling-charts-highcharts" % gatlingVersion % "test",
    "io.gatling" % "gatling-test-framework" % gatlingVersion % "test",
scalacOptions := Seq(


So I tested with some bland command on sbt shell such as:

javaOptions Gatling/testOnly *.testClass
Gatling/testOnly *.testClass javaOptions

But none of it works, is there what I missing in syntax of command or settings that I should be aware of ?
Thank you.

I found the way, answered on stack by @slandelle (many thanks) here
The correct syntax now (outside sbt shell) is:

sbt -Dparam=value "Gatling/testOnly *.testClass"

My 2 cents: This should be mentioned on docs page.
Thank you


Nowadays, we recommend against going with Gatling Scala unless you’re a trained Scala developer. Even more strongly, we recommend against using sbt unless you’re a trained sbt user.

Here, your question is not related to Gatling but only related to customizing sbt execution. It would be best to ask this kind of question to a Scala/sbt community or StackOverflow.

Hi @slandelle ,

I understand when it comes to stack, because not many people uses Scala, counted me.
I’m willing to prompt my team to move to Java, but I need some solid evidences to make the move, can you share some of your insights for this one?

Note that I’m absolutely agree on using Gatling-Java :slight_smile:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.