How to Setup and Configure JMeter in Windows

H

JMeter is one of most popular performance testing tool and since it is open-source, therefore it is often a start point for beginners in performance testing. In this blog, I will share a step-by-step guide that can be used to install JMeter in Windows environment. There will also be some configuration and script designing tips which you will find useful while working on real-time JMeter projects.

1- Setup and Verify Java

Apache JMeter is purely a Java based tool; therefore first of all we need to make sure that Java is properly installed and configured in our system. If you are already using any java based applications, then Java might already be installed on your system. To check if Java is already installed open command prompt and run command java -version.

If Java is successfully installed and configured then the command will return valid java version number (java version “x.x.x.x”) as shown in image below:

If Java is not installed or configured, then you may get a message like this: “java” is not recognized as an internal or external command, operable program or batch file.

To fix it, you need to download and install valid java JRE or JDK corresponding to your operating system. Java JRE or JDK can be download from Java Download page on Oracle website. After successful installation of JRE/JDK, open command prompt again and run the command java -version . It should now return java version number that you installed. If you still do not get the valid response after above steps, then you may look into setting java environment variables under windows system properties.

It is very important to have correct version of java on your system to get maximum out of JMeter. For example, using a 32 bit java on a 64 bit operating system can lead to under-utilization of resources.

2- Download and Install JMeter

To download JMeter simply go to official Apache JMeter website and download the zip or tgz package.

Apache JMeter Download

After downloading the file, just unzip it anywhere in your system. In the unzipped folder there are all the files which JMeter requires for its functioning.

3- Configure JMeter for better performance

There are many ways to optimize JMeter for better performance. It is a complete topic in itself but for starter, I will recommend at least configuring java xms and xmx values in JMeter.bat file. By doing so, you can make sure that JMeter is properly using the available memory resources. It also reduces the chances of OutOfMemory errors.

To change these settings, open jmeter.bat file in notepad and update following lines

// default configuration

set HEAP=-Xms512m -Xmx512m
set NEW=-XX:NewSize=128m -XX:MaxNewSize=128m
// new settings could be like this *depending* on your hardware and software specs
// note that, Max heap size should not exceed the 80% of total system memory

set HEAP=-Xms512m -Xmx2048m
set NEW=-XX:NewSize=128m -XX:MaxNewSize=1024m

Other than this configuration, it is also important to use listeners intelligently in your test plan. Listeners that consume more memory like Table, Tree, Assertion and Graph listeners should be avoided during actual load test execution. It is best to only generate JTL test results file during actual load tests and later that JTL file can be used to create different reports.

4- Launch JMeter & Execute JMeter scripts

There are multiple ways to start JMeter. We can start it in GUI mode by opening jmeter.bat file or we can simply run commands in CMD to execute jmeter scripts without opening it in GUI mode.

4.1) To open JMeter GUI, just navigate to apache-jmeter-2.13>bin directory and double-click ApacheJMeter.jar or jmeter.bat file.

Steps to launch JMeter GUI

It should open up JMeter in GUI mode as in image below:

4.2) As discussed earlier, JMeter consumes lot of system resources while running in GUI mode. Therefore, it is best to use it in command-line non-GUI mode while performing actual load tests. JMeter scripts can be executed from CMD by using command below:

jmeter -n -t myScript.jmx 

Where...

–n means that JMeter will run in command line mode
-t myScript.jmx mentions the path and Filename of JMeter script

There are other parameter as well which you can pass along with command like path to JTL results file, server IP and port number etc. Command prompt will show progress messages during the script execution and also a summary after successful execution of script. You may also check additional tips for JMeter tuning in my other blog.

Still face any issues while setting up JMeter? Feel free to ask and I will try my best to help out 🙂

Arif Masood

Software Quality Professional. Perfectionist. Love to explore new tools, technologlies & processes. Worked on several web & mobile projects in last 7+ years. Mostly in areas of Functional, API, Automation & Performance testing. Ocassional blogger - trying to be more regular one :)

Posts

Tags