---
title: How To Use Custom Jars in JMeter and Loadium?
description: Loadium blog
image: https://cdn-images-1.medium.com/max/2560/1*8zwFMUSQ48WHRWnHGi5z3g.jpeg
---

[Skip to content](https://explore.loadium.com/loadium-blog/best-practices-for-api-security-testing-1-0-0-0-0-0-0-0-0-0-1-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-1756-a5baa1e3#main-content)

 Sep 8, 2025 10:13:07 AM

# How To Use Custom Jars in JMeter and Loadium?

![Picture of Erdem KIRMIZI](https://explore.loadium.com/hs-fs/hubfs/bio.jpg?width=50&name=bio.jpg) [Erdem KIRMIZI](https://explore.loadium.com/loadium-blog/authors/erdem-kirmizi)

Share: [facebook-f icon](http://www.facebook.com/share.php?u=https://explore.loadium.com/loadium-blog/best-practices-for-api-security-testing-1-0-0-0-0-0-0-0-0-0-1-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-1756-a5baa1e3) [linkedin-in icon](http://www.linkedin.com/shareArticle?mini=true&url=https://explore.loadium.com/loadium-blog/best-practices-for-api-security-testing-1-0-0-0-0-0-0-0-0-0-1-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-1756-a5baa1e3) [Twitter icon](https://twitter.com/intent/tweet?url=https://explore.loadium.com/loadium-blog/best-practices-for-api-security-testing-1-0-0-0-0-0-0-0-0-0-1-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-1756-a5baa1e3) [pinterest-p icon](http://pinterest.com/pin/create/link/?url=https://explore.loadium.com/loadium-blog/best-practices-for-api-security-testing-1-0-0-0-0-0-0-0-0-0-1-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-1756-a5baa1e3) [envelope icon](mailto:?body=https://explore.loadium.com/loadium-blog/best-practices-for-api-security-testing-1-0-0-0-0-0-0-0-0-0-1-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-1756-a5baa1e3)

![](https://cdn-images-1.medium.com/max/2560/1*8zwFMUSQ48WHRWnHGi5z3g.jpeg)

### 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:

![](https://cdn-images-1.medium.com/max/800/0*v_-XNRg4--xo-l3R.png)

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:

![](https://cdn-images-1.medium.com/max/800/0*vyhjGQkAUVO3tO-G.png)

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.

![](https://cdn-images-1.medium.com/max/800/0*pmibZKuFnU9Gkm7Z.png)

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.

![](https://cdn-images-1.medium.com/max/800/0*Oa4Jgq-CucgTWv3S.png)

Run your test plan, and the result is below.

![](https://cdn-images-1.medium.com/max/800/0*04oy_9AfpByJuzVc.png)

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.

![](https://cdn-images-1.medium.com/max/800/0*GkrjTxTj1YR7AMvm.png)

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

![](https://cdn-images-1.medium.com/max/800/0*vZuYpL4pUDEnRppK.png)

The result is below:

![](https://cdn-images-1.medium.com/max/800/0*FprhTKun_GQnej7m.png)

Please feel free to [ask](https://loadium.com/contact-us/) questions if you have any.

Happ load testing!

## Related posts

[![](https://cdn-images-1.medium.com/max/800/1*Rh7DupMcEbMx0tECeaUSxg.jpeg)](https://explore.loadium.com/loadium-blog/the-latest-jmeter-update-jmeter-5-6)

[JMeter](https://explore.loadium.com/loadium-blog/tag/jmeter), [Load Testing](https://explore.loadium.com/loadium-blog/tag/load-testing)

## [The Latest JMeter Update: JMeter 5.6](https://explore.loadium.com/loadium-blog/the-latest-jmeter-update-jmeter-5-6)

![Picture of Erdem KIRMIZI](https://explore.loadium.com/hs-fs/hubfs/bio.jpg?width=50&name=bio.jpg) [Erdem KIRMIZI](https://explore.loadium.com/loadium-blog/authors/erdem-kirmizi) 

 Sep 8, 2025 11:15:24 AM

The Apache JMeter team announced its latest update, JMeter version 5.6, in August 2023. Let’s now...

[Read more](https://explore.loadium.com/loadium-blog/the-latest-jmeter-update-jmeter-5-6)

[![](https://cdn-images-1.medium.com/max/2560/1*CVMMNDBTrjqCzzfC6QzErg.png)](https://explore.loadium.com/loadium-blog/best-practices-for-api-security-testing-1-0-0-0-0-0-0-0-0-0-1-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-1756-6ad60dc2)

[JMeter](https://explore.loadium.com/loadium-blog/tag/jmeter)

## [JMeter Timers](https://explore.loadium.com/loadium-blog/best-practices-for-api-security-testing-1-0-0-0-0-0-0-0-0-0-1-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-1756-6ad60dc2)

![Picture of Erdem KIRMIZI](https://explore.loadium.com/hs-fs/hubfs/bio.jpg?width=50&name=bio.jpg) [Erdem KIRMIZI](https://explore.loadium.com/loadium-blog/authors/erdem-kirmizi) 

 Sep 8, 2025 10:39:43 AM

Why Do I Need a Timer in JMeter? User behavior in load tests depends on many factors. Those factors...

[Read more](https://explore.loadium.com/loadium-blog/best-practices-for-api-security-testing-1-0-0-0-0-0-0-0-0-0-1-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-1756-6ad60dc2)

[![](https://cdn-images-1.medium.com/max/2560/1*05kXZVlY4w7VCRcQ_W9Hnw.png)](https://explore.loadium.com/loadium-blog/scopes-in-jmeter)

[Tools](https://explore.loadium.com/loadium-blog/tag/tools), [JMeter](https://explore.loadium.com/loadium-blog/tag/jmeter)

## [Scopes in JMeter](https://explore.loadium.com/loadium-blog/scopes-in-jmeter)

![Picture of Erdem KIRMIZI](https://explore.loadium.com/hs-fs/hubfs/bio.jpg?width=50&name=bio.jpg) [Erdem KIRMIZI](https://explore.loadium.com/loadium-blog/authors/erdem-kirmizi) 

 Sep 8, 2025 11:03:21 AM

As you all know, JMeter runs performance test scripts on Test Plans. Those test plans are...

[Read more](https://explore.loadium.com/loadium-blog/scopes-in-jmeter)

---

```json
{
  "@context" : "https://schema.org",
  "@type" : "BlogPosting",
  "author" : {
    "@type" : "Person",
    "name" : "Erdem KIRMIZI",
    "url" : "https://explore.loadium.com/loadium-blog/author/erdem-kirmizi"
  },
  "dateModified" : "2025-09-08T07:13:07.364Z",
  "datePublished" : "2025-09-08T07:13:07.000Z",
  "headline" : "How To Use Custom Jars in JMeter and Loadium?",
  "image" : [ "https://cdn-images-1.medium.com/max/2560/1*8zwFMUSQ48WHRWnHGi5z3g.jpeg" ],
  "mainEntityOfPage" : {
    "@id" : "https://explore.loadium.com/loadium-blog/best-practices-for-api-security-testing-1-0-0-0-0-0-0-0-0-0-1-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-1756-a5baa1e3",
    "@type" : "WebPage"
  },
  "publisher" : {
    "@type" : "Organization",
    "logo" : {
      "@type" : "ImageObject",
      "url" : "https://explore.loadium.com/hubfs/Logo-1.png"
    },
    "name" : "Loadium"
  }
}
```