# Invoking Gatling Simulation with command line parameters from Java code

**URL:** <https://community.gatling.io/t/invoking-gatling-simulation-with-command-line-parameters-from-java-code/2538>\
**Category:** Gatling (Open-Source)\
**Created:** [September 17, 2015, 5:08pm UTC](https://community.gatling.io/t/invoking-gatling-simulation-with-command-line-parameters-from-java-code/2538 "2015-09-17T17:08:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sujoy\_Bhattacharya](https://avatars.discourse-cdn.com/v4/letter/s/ac91a4/32.png) [@Sujoy\_Bhattacharya](https://community.gatling.io/u/Sujoy_Bhattacharya)\
**Post date:** [September 17, 2015, 5:08pm UTC](https://community.gatling.io/t/invoking-gatling-simulation-with-command-line-parameters-from-java-code/2538/1 "2015-09-17T17:08:56Z")

</div>

I can run Gatling simulation using the following script from command line.  
JAVA\_OPTS="-XX:-MaxFDLimit -Dusers=1" JAVA\_CLASSPATH=`pwd` $GATLING\_SH -sf `pwd` -s FanFlow

However I want to do it from a java code as I want to keep the Gatling simulation and the java class(lets call that as SimulationDriver) in a single jar.

I came across the Gatling.fromArgs api and was able to run it as a simulation  
using the following piece of code(This is basically my SimulationDriver). But I would also like to pass the command line arguments to the Gatling simulation from the java code.(like -Dusers).  
Is there a way to do that?

Gatling.fromArgs(new String[] { “-s”, “FanFlowSimulation” },

new Option\<Class\>() {

private static final long serialVersionUID = 1L;

@Override

public int productArity() {

return 0;

}

@Override

public Object productElement(int arg0) {

return null;

}

@SuppressWarnings(“unchecked”)

@Override

public Class get() {

try {

return (Class) Class

.forName(MySimulation.class

.getCanonicalName());

} catch (ClassNotFoundException e) {

}

return null;

}

@Override

public boolean isEmpty() {

return false;

}

@Override

public boolean canEqual(Object o) {

return false;

}

});

---

<div class="post-metadata">

**Author:** ![Sujoy\_Bhattacharya](https://avatars.discourse-cdn.com/v4/letter/s/ac91a4/32.png) [@Sujoy\_Bhattacharya](https://community.gatling.io/u/Sujoy_Bhattacharya)\
**Post date:** [September 17, 2015, 6:08pm UTC](https://community.gatling.io/t/invoking-gatling-simulation-with-command-line-parameters-from-java-code/2538/2 "2015-09-17T18:08:30Z")

</div>

Any pointers folks?

---

<div class="post-metadata">

**Author:** ![Abhinav\_Gogna](https://avatars.discourse-cdn.com/v4/letter/a/c0e974/32.png) [@Abhinav\_Gogna](https://community.gatling.io/u/Abhinav_Gogna)\
**Post date:** [September 18, 2015, 1:44am UTC](https://community.gatling.io/t/invoking-gatling-simulation-with-command-line-parameters-from-java-code/2538/3 "2015-09-18T01:44:44Z")

</div>

I am not sure that’s possible. Would be interested to know if there is a way.
