How to install Apache JMeter and Launch JMeter

As JMeter is a 100% Java application, so java needs to be installed with a JAVA_HOME environment variable. To check if java is installed, open the command prompt and type command java –version to check. If Java is installed successfully, then please proceed else install java and then Just Download JMeter and install by unzipping the .zip or .tgz file in any location. For latest version of Apache JMeter 3.0 requires Java 7 or later version. Please check operating systems which are tested with JMeter on JMeter Wiki Page.

There is basically no installation needed for the Jmeter, you don't execute or the set up file to install it. Download latest version of JMeter from the Official site which is always recommended. Once you download the zip, extract it locally in your system (you can keep this directory anywhere in your system). Ensure you install JAVA version which is compatible and the Java environment variable path correctly set. That's all Done, there is nothing more for you to do.

The directory structure should look something like this:

apache-jmeter-3.0
apache-jmeter-3.0/bin
apache-jmeter-3.0/docs
apache-jmeter-3.0/extras
apache-jmeter-3.0/lib/
apache-jmeter-3.0/licenses
apache-jmeter-3.0/printable_docs
apache-jmeter-3.0/LICENSE
apache-jmeter-3.0/NOTICE
apache-jmeter-3.0/README

This is how it looks like:

Apache JMeter folder structure

You can rename the parent directory (i.e. apache-jmeter-X.Y) if you want, but do not change any of the sub-directory names.

There are some additional scripts in the bin directory that you may find useful. Windows script files (the .CMD files require Win2K or later):

jmeter.bat
- run JMeter (in GUI mode by default)
jmeterw.cmd
- run JMeter without the windows shell console (in GUI mode by default)
jmeter-n.cmd
- drop a JMX file on this to run a non-GUI test
jmeter-n-r.cmd
- drop a JMX file on this to run a non-GUI test remotely
jmeter-t.cmd
- drop a JMX file on this to load it in GUI mode
jmeter-server.bat
- start JMeter in server mode
mirror-server.cmd
- runs the JMeter Mirror Server in non-GUI mode
shutdown.cmd
- Run the Shutdown client to stop a non-GUI instance gracefully
stoptest.cmd
- Run the Shutdown client to stop a non-GUI instance abruptly

You can launch JMeter in multiple ways, JMeter GUI and Non GUI/command line mode. let us see how to do:-

How to launch JMeter in GUI Mode?

The first and easiest way to launch JMeter is by double-clicking on jmeter.bat (for Windows) or jmeter.sh (for UNIX) file. You can find these files in the Apache JMeter - > bin directory. Within a short time, the JMeter GUI should appear on the screen.

If any error occurs then it may be cause of incompatible java version / issue in Java environment variable path, or JMeter file missing/corrupted. Try to solve these issue before moving forward.

Make sure you run the jmeter.bat file as administrator, if not sometimes you may see error as 'java.util.prefs.WindowsPreferences WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.

Here is how where you can find jmeter.bat file in your jmeter->bin directory

Apache JMeter bat file location

Launching JMeter in GUI mode is perfect for adding, editing new configuration elements, thread groups and samplers as a result of which we can view a number of different listeners helping for debugging.

On the other hand, it consumes more resources. GUI mode does have a limitation which slows down the CPU recourse utilization while running the script. If we are running multiple listeners in a script, it affects the performance of JMeter.

Hence to overcome such a situation, to save resources, we should run JMeter in the non-GUI mode.

How to launch JMeter in Non GUI/command line mode?

Running JMeter using command line in Non-GUI mode is very simple,

Just Go into JMeter’s bin directory, Open command prompt, To open command prompt in the directory, Press Shift and Right Click where it will show you an option as 'Open Command Window here' and enter the following command

jmeter -n –t testScript.jmx -l testResults.jtl

Let us see the jmeter parameters that are used in the above command

-n: This specifies JMeter to run in non-gui mode
-t: The name of JMX file which contains the Test Plan [ex: testScript.jmx]
-l: This specifies JMeter to log results.
-j: Name of JMeter run log file (JMeter text logs) to log results.

Apart from the above mentioned parameters, JMeter has many other parameters that can be used when running in the non-GUI mode. The below options are used for remote execution of JMeter tests and when using JMeter through a firewall/proxy server.

-r: Run the test in the servers specified by the JMeter property "remote_hosts"
-R: list of remote servers
-H: proxy server hostname or ip address
-P: proxy server port
-u: username for proxy authentication - when required
-a: password for proxy authentication - when required

Example command to specify the firewall/proxy server hostname and port number information

jmeter -n -t testScript.jmx -l testLog.jtl -H test.proxy.server -P 8000

Example command with username and password:

jmeter -H test.proxy.server -P 8000 -u username -a password -N localhost

Proxy Settings can also be defined in a Test Plan, using the HTTP Request Defaults configuration or bu using HTTP Request sampler elements.

JMeter Tutorials: 

Add new comment