---
title: "__jexl2"
description: "JMeter __jexl2 function reference: syntax, parameters, and practical examples for parameterizing test plans with dynamic values."
url: https://docs.jmeter.ai/functions/jexl2/
lastUpdated: 2026-10-01
source: docs.jmeter.ai
---

# __jexl2

*Also documented in context in the [full Functions and Variables reference](/user-manual/functions/#__jexl2).*

The jexl function returns the result of evaluating a
[Commons JEXL expression](http://commons.apache.org/jexl).
See links below for more information on JEXL expressions.

The `__jexl2` function uses Commons JEXL 2

- [JEXL syntax description](http://commons.apache.org/proper/commons-jexl/reference/syntax.html)
- [JEXL examples](http://commons.apache.org/proper/commons-jexl/reference/examples.html#Example_Expressions)

| Name | Required | Description |
| --- | --- | --- |
| Expression | Yes | The expression to be evaluated. For example, `6*(5+2)` |
| Name of variable | No | The name of the variable to set. |

The following variables are made available to the script:

- `log` - the [Logger](https://www.slf4j.org/api/org/slf4j/Logger.html) for the function
- `ctx` - [JMeterContext](https://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterContext.html) object
- `vars` - [JMeterVariables](https://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterVariables.html) object
- `props` - JMeterProperties (class [`java.util.Properties`](https://docs.oracle.com/javase/8/docs/api/java/util/Properties.html)) object
- `threadName` - String containing the current thread name
- `sampler` - current [Sampler](https://jmeter.apache.org/api/org/apache/jmeter/samplers/Sampler.html) object (if any)
- `sampleResult` - previous [SampleResult](https://jmeter.apache.org/api/org/apache/jmeter/samplers/SampleResult.html) object (if any)
- `OUT` - System.out - e.g. `OUT.println("message")`

Jexl can also create classes and call methods on them, for example:

```plaintext
Systemclass=log.class.forName("java.lang.System");
now=Systemclass.currentTimeMillis();
```

Note that the Jexl documentation on the web-site wrongly suggests that “`div`” does integer division.
In fact “`div`” and “`/`” both perform normal division. One can get the same effect
as follows:

```plaintext
i= 5 / 2;
i.intValue(); // or use i.longValue()
```

> **Note**
> JMeter allows the expression to contain multiple statements.

## Related

- [Functions and Variables Guide](/topics/functions-and-variables/)
- [Regex Extractor Builder](/tools/regex-tester/)
- [Full Functions Reference](/user-manual/functions/)
- [Component Reference](/user-manual/component-reference/)
