How To Upload File in Jmeter
How To Use Custom Jars in JMeter and Loadium?
How To Use Custom Jars in JMeter and Loadium?

Why do you need to use custom jars in Jmeter?
In some cases, we need to share or pass variables between threads and thread groups in JMeter. There are a few ways to do this and using custom jars in Jmeter is one of them. At Jmeter documentation:

But sometimes we want to ensure synchronization between threads and thread groups. In this case, one of the best ways is to “write your own Java classes.”
Creating a Custom Jar
- Create a new java class in your favorite IDE. Our java package structure is as follows:

Create the methods that you need in your test. In this example, we created methods about BlockingQueue operations.
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
public class Loadium {
private static LinkedBlockingQueue<Object> queue = new LinkedBlockingQueue<>();
public static void put(Object obj) throws InterruptedException {
queue.put(obj);
}
public static Object take() throws Exception {
return queue.take();
}
public static Object get(long timeout) throws Exception {
return queue.poll(timeout, TimeUnit.MILLISECONDS);
}
public static void clear() throws Exception {
queue.clear();
}
public static int size() throws Exception {
return queue.size();
}
}
- Create a JAR file by following this instruction “Click Build->Build Artifacts.” Then a jar will be created in your workspace.

Copy and paste the jar file in <your JMeter path>/lib folder.
- Restart JMeter to load this JAR file.
Using the custom jar in your JMeter script
In this section, we will learn how to use the custom class in JMeter script.
- Create a Test Plan in your JMeter GUI.
- Add a Thread Group element.
- Add a BeanShell Sampler to your test plan.
Now we can call our custom method as follows in BeanShell Sampler element.

Run your test plan, and the result is below.

How To Use Custom Jars On Loadium?
- Upload the JMX file.
- Add your JAR file.
- Set your JMeter configuration as thread count, engine count, etc.
- Save and run your test on Loadium.

For reporting purposes, go to Logs tab in your test report.

The result is below:

Please feel free to ask questions if you have any.
Happ load testing!