JMeter – Launching Modes

After the successful installation of JMeter, the next step is to launch the JMeter tool for scripting purposes. Although the launching of Apache JMeter tool is not a big thing, still the purpose of this article is to provide knowledge of different launching modes of JMeter.

There are 3 modes to launch the Apache JMeter application on your system. Each mode has its own benefits:

  1. GUI Mode
  2. Command Line Mode (Non-GUI Mode)
  3. Server Mode (Non-GUI Mode)

Tip: GUI mode is generally used for creating the test script, Non-GUI mode must be used for load testing because Non-GUI mode consumes less memory.

1. JMeter GUI Mode

Purpose: The GUI mode is used for preparing the test script, debugging the script and performing the smoke test. In this mode, JMeter consumes relatively more memory than in Non-GUI mode.

For Windows and Mac users, JMeter has the simplest way to launch the GUI. Navigate to the /bin folder of Apache JMeter and double-click on jmeter.bat. This will first open the JMeter console followed by JMeter GUI.

To open JMeter GUI through the Windows command line, you need to follow below steps:

  1. Go to ‘Run’
  2. Type ‘cmd’
  3. Navigate to /bin folder of Apache JMeter
  4. Type ‘jmeter.bat’
  5. Hit the ‘Enter’ key

Watch YouTube Video: Link

2. JMeter Non-GUI Mode

Purpose: The Non-GUI mode is used for test execution because JMeter consumes less memory in this mode; helps to provide more space for threads and prevents test failure due to lack of memory.

To launch the JMeter or execute the test in Non-GUI mode, you need to open the console, navigate to the /bin folder of Apache JMeter and run the below command:

For Windows: jmeter -n -t <script name with path> -l <log file name with path>

For Unix: ./jmeter.sh -n -t <script name with path> -l <log file name with path>

In addition, if you want to know about all the arguments for the JMeter command then type ‘jmeter -?’, and you will get the below output:

    --?
            print command line options and exit
    -h, --help
            print usage information and exit
    -v, --version
            print the version information and exit
    -p, --propfile <argument>
            the jmeter property file to use
    -q, --addprop <argument>
            additional JMeter property file(s)
    -t, --testfile <argument>
            the jmeter test(.jmx) file to run. "-t LAST" will load last
            used file
    -l, --logfile <argument>
            the file to log samples to
    -i, --jmeterlogconf <argument>
            jmeter logging configuration file (log4j2.xml)
    -j, --jmeterlogfile <argument>
            jmeter run log file (jmeter.log)
    -n, --nongui
            run JMeter in nongui mode
    -s, --server
            run the JMeter server
    -E, --proxyScheme <argument>
            Set a proxy scheme to use for the proxy server
    -H, --proxyHost <argument>
            Set a proxy server for JMeter to use
    -P, --proxyPort <argument>
            Set proxy server port for JMeter to use
    -N, --nonProxyHosts <argument>
            Set nonproxy host list (e.g. *.apache.org|localhost)
    -u, --username <argument>
            Set username for proxy server that JMeter is to use
    -a, --password <argument>
            Set password for proxy server that JMeter is to use
    -J, --jmeterproperty <argument>=<value>
            Define additional JMeter properties
    -G, --globalproperty <argument>=<value>
            Define Global properties (sent to servers)
            e.g. -Gport=123
             or -Gglobal.properties
    -D, --systemproperty <argument>=<value>
            Define additional system properties
    -S, --systemPropertyFile <argument>
            additional system property file(s)
    -f, --forceDeleteResultFile
            force delete existing results files and web report folder if
             present before starting the test
    -L, --loglevel <argument>=<value>
            [category=]level e.g. jorphan=INFO, jmeter.util=DEBUG or com
            .example.foo=WARN
    -r, --runremote
            Start remote servers (as defined in remote_hosts)
    -R, --remotestart <argument>
            Start these remote servers (overrides remote_hosts)
    -d, --homedir <argument>
            the jmeter home directory to use
    -X, --remoteexit
            Exit the remote servers at end of test (non-GUI)
    -g, --reportonly <argument>
            generate report dashboard only, from a test results file
    -e, --reportatendofloadtests
            generate report dashboard after load test
    -o, --reportoutputfolder <argument>
            output folder for report dashboard

To stop the test in the middle, again you need to navigate to the /bin folder of JMeter and type stoptest in the command prompt for Windows machine and ./stoptest.sh for Unix machine. If more than one JMeter test script is executed then you need to stop the individual script by appending the process ID into the stop command like stoptest 4445.

There are some additional useful commands for Windows OS:

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

3. JMeter Server Non-GUI Mode

Purpose: Server mode is used for distributed testing. This testing works as a client-server model. In this model, start the server(s) by running jmeter-server[.bat] on each server host and control those servers using GUI mode.

The script also lets you specify the optional firewall/proxy server information:
-H [proxy server hostname or IP address]
-P [proxy server port]

Example: jmeter-server -H proxy.server -P 8080

If you are testing from behind a firewall/proxy server, you need to provide JMeter with the firewall/proxy server hostname and port number. 

-H [proxy server hostname or IP address]
-P [proxy server port]
-N [nonproxy hosts]
-u [username for proxy authentication – if required]
-a [password for proxy authentication – if required]

Example: jmeter -H proxy.server -P 8080 -u myname -a mypassword -N localhost

To execute the test in server non-GUI mode, first navigate to bin folder of JMeter and run the following command:

For Windows: jmeter -n -t <script path> -l <log file path> -r

For Unix: ./jmeter.sh -n -t <script path> -l <log file path> -r

The test can also be executed by selecting specific slave machines.

For Windows: jmeter -n -t <script path> -l <log file path> -R server1,server2,server3,

For Unix: ./jmeter.sh -n -t <script path> -l <log file path> -R server1,server2,server,


You may be interested:


Leave a Comment