Skip to content

Java Request

Configure the JMeter Java Request samplers: properties, defaults, and practical usage notes for building reliable load tests.

Difficulty
intermediate
Guide type
reference
Estimated read time
2 min read
Last verified version
Verified JMeter 5.6

Part of the Samplers category. Also documented in context in the full Component Reference.

Java Request

This sampler lets you control a java class that implements the org.apache.jmeter.protocol.java.sampler.JavaSamplerClient interface. By writing your own implementation of this interface, you can use JMeter to harness multiple threads, input parameter control, and data collection.

The pull-down menu provides the list of all such implementations found by JMeter in its classpath. The parameters can then be specified in the table below - as defined by your implementation. Two simple examples (JavaTest and SleepTest) are provided.

The JavaTest example sampler can be useful for checking test plans, because it allows one to set values in almost all the fields. These can then be used by Assertions, etc. The fields allow variables to be used, so the values of these can readily be seen.

NameRequiredDescription
NameNoDescriptive name for this sampler that is shown in the tree.
ClassnameYesThe specific implementation of the JavaSamplerClient interface to be sampled.
Send Parameters with RequestNoA list of arguments that will be passed to the sampled class. All arguments are sent as Strings. See below for specific settings.

The following parameters apply to the SleepTest and JavaTest implementations:

NameRequiredDescription
Sleep_timeYesHow long to sleep for (ms)
Sleep_maskYesHow much “randomness” to add: The sleep time is calculated as follows: totalSleepTime = SleepTime + (System.currentTimeMillis() % SleepMask)

The following parameters apply additionally to the JavaTest implementation:

NameRequiredDescription
LabelNoThe label to use. If provided, overrides Name
ResponseCodeNoIf provided, sets the SampleResult ResponseCode.
ResponseMessageNoIf provided, sets the SampleResult ResponseMessage.
StatusNoIf provided, sets the SampleResult Status. If this equals “OK” (ignoring case) then the status is set to success, otherwise the sample is marked as failed.
SamplerDataNoIf provided, sets the SampleResult SamplerData.
ResultDataNoIf provided, sets the SampleResult ResultData.
On this page