Installing and Configuring Apache JMeter on Ubuntu
JMeter is a Java-based tool, so a Java Development Kit (JDK) is required. Use OpenJDK (recommended for Ubuntu) for simplicity:
sudo apt update
sudo apt install openjdk-11-jdk # Use openjdk-8-jdk for legacy JMeter versions (e.g., 3.x)
Verify installation:
java -version
You should see output like openjdk version "11.0.xx" (confirm the version matches JMeter’s compatibility—most recent JMeter versions support Java 11+).
Download the latest stable JMeter release from the official Apache website. For example (replace 5.6.3 with the latest version):
wget https://dlcdn.apache.org//jmeter/binaries/apache-jmeter-5.6.3.tgz
Extract the tarball to a directory (e.g., /opt for system-wide access):
sudo tar -xzf apache-jmeter-5.6.3.tgz -C /opt
Rename the extracted folder for consistency (optional but recommended):
sudo mv /opt/apache-jmeter-5.6.3 /opt/jmeter
To run JMeter from any terminal, add its bin directory to your PATH and set the JMETER_HOME variable. Edit the global profile file:
sudo nano /etc/profile
Add the following lines at the end (adjust paths if you used a different installation directory):
export JMETER_HOME=/opt/jmeter
export PATH=$JMETER_HOME/bin:$PATH
Save the file (Ctrl+O, Enter, Ctrl+X) and apply changes:
source /etc/profile
Verify JMeter is accessible:
jmeter -v
You should see JMeter’s version, Java version, and other system info.
To use the graphical interface (for building test plans), execute:
jmeter
This opens the JMeter GUI, where you can add threads, HTTP requests, listeners (e.g., “View Results Tree”), and other components. Save your test plan as a .jmx file (e.g., my_test_plan.jmx).
For load testing, use non-GUI mode to minimize resource usage. Replace <test-plan-path> with the path to your .jmx file and <log-file-path> with the desired results file:
jmeter -n -t <test-plan-path> -l <log-file-path>
Example:
jmeter -n -t /opt/jmeter/my_test_plan.jmx -l /opt/jmeter/results.jtl
After the test completes, analyze results using JMeter’s GUI:
jmeter -g /opt/jmeter/results.jtl -o /opt/jmeter/report
This generates an HTML report in the /opt/jmeter/report directory.
To extend JMeter’s capabilities (e.g., WebSocket support, advanced reporting), install the JMeter Plugins Manager:
lib/ext directory:sudo cp jmeter-plugins-manager-1.7.jar /opt/jmeter/lib/ext/
JAVA_HOME is set (run echo $JAVA_HOME to verify).NoClassDefFoundError (e.g., for WebSocket plugins), install the required JARs (e.g., jetty-http, websocket-common) in the lib/ext directory.sudo or ensure the bin directory has execute permissions (sudo chmod +x /opt/jmeter/bin/jmeter).