# Java\_opts in sbt

**URL:** <https://community.gatling.io/t/java-opts-in-sbt/9039>\
**Category:** Gatling (Open-Source)\
**Created:** [May 30, 2024, 2:12am UTC](https://community.gatling.io/t/java-opts-in-sbt/9039 "2024-05-30T02:12:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![trinp](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/trinp/32/1593_2.png) [@trinp](https://community.gatling.io/u/trinp)\
**Post date:** [May 30, 2024, 2:12am UTC](https://community.gatling.io/t/java-opts-in-sbt/9039/1 "2024-05-30T02:12:16Z")

</div>

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

I read the [guidelines](https://community.gatling.io/t/welcome-in-the-gatling-community-our-code-of-conduct/6462) and [how to ask a question](https://community.gatling.io/t/how-to-ask-a-question/6538) topics.  
 I provided a [SSCCE](http://www.sscce.org/) (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:

```auto
JAVA_OPTS="-Dparam=value" ./bin/gatling.sh -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)

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

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

fork := true
javaOptions ++= Seq(
  s"-Dparam=$value"
)

libraryDependencies ++= Seq(
    "io.gatling.highcharts" % "gatling-charts-highcharts" % gatlingVersion % "test",
    "io.gatling" % "gatling-test-framework" % gatlingVersion % "test",
)
scalacOptions := Seq(
  "-encoding", 
  "UTF-8", 
  "-release:8", 
  "-deprecation",
  "-feature", 
  "-unchecked", 
  "-language:implicitConversions", 
  "-language:postfixOps")

enablePlugins(GatlingPlugin)

```

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

```auto
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.

---

<div class="post-metadata">

**Author:** ![trinp](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/trinp/32/1593_2.png) [@trinp](https://community.gatling.io/u/trinp)\
**Post date:** [May 30, 2024, 4:58am UTC](https://community.gatling.io/t/java-opts-in-sbt/9039/2 "2024-05-30T04:58:15Z")

</div>

I found the way, answered on stack by @slandelle (many thanks) [here](https://stackoverflow.com/questions/72141679/cannot-pass-arguments-using-sbt-to-gatling-simulation)  
The correct syntax now (outside sbt shell) is:

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

```

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

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [May 30, 2024, 5:21am UTC](https://community.gatling.io/t/java-opts-in-sbt/9039/3 "2024-05-30T05:21:14Z")

</div>

Hi,

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.

---

<div class="post-metadata">

**Author:** ![trinp](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/trinp/32/1593_2.png) [@trinp](https://community.gatling.io/u/trinp)\
**Post date:** [May 30, 2024, 6:00am UTC](https://community.gatling.io/t/java-opts-in-sbt/9039/4 "2024-05-30T06:00:24Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [May 30, 2024, 6:01am UTC](https://community.gatling.io/t/java-opts-in-sbt/9039/5 "2024-05-30T06:01:43Z")

</div>

> **[Java, Kotlin, Scala To Do Load Testing | Gatling Blog](https://gatling.io/blog/java-kotlin-or-scala-which-gatling-flavor-is-right-for-you)**
>
> In October, 2021 Gatling expanded its offer from just a Scala API to include a Java API as well. The additional API now lets developers choose to script using Java, Kotlin, or Scala.

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/flex013/uploads/gatling2/original/2X/b/b148e0742de35c6280726cabf3ecd3de2d320f63.png) [@system](https://community.gatling.io/u/system)\
**Post date:** [June 29, 2024, 6:02am UTC](https://community.gatling.io/t/java-opts-in-sbt/9039/6 "2024-06-29T06:02:22Z")

</div>

Closed on June 29, 2024, 6:02am UTC

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