Installing and Running JMeter

Installing and Running JMeter

Installing and Running JMeter- Installation- We recommend that most users run the latest release. To install a release build, simply unzip the zip/tar file into the directory where you want J Meter to be installed. Provided that you have a JRE/JDK correctly installed and the JAVA_HOME environment variable set, there is nothing more for you to do.

Note: there can be problems (especially with client-server mode) if the directory path contains any spaces.

Installing and Running JMeter- The installation directory structure should look something like this (where X.Y is version number):

apache-j meter-X.Y

apache-j meter-X.Y/bin

apache-j meter-X.Y/docs

apache-j meter-X.Y/extras

apache-j meter-X.Y/lib/

apache-j meter-X.Y/lib/ext

apache-j meter-X.Y/lib/junit

apache-j meter-X.Y/licenses

apache-j meter-X.Y/printable_docs

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

Installing and Running JMeter- Running J Meter

To run J Meter, run the j meter.bat (for Windows) or j meter (for Unix) file. These files are found in the bin directory. After a short time, the J Meter GUI should appear.

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

  • j meter.bat – run JMeter (in GUI mode by default)
  • j meter-n.cmd – drop a JMX file on this to run a non-GUI test
  • j meter-n-r.cmd – drop a JMX file on this to run a non-GUI test remotely
  • j meter-t.cmd – drop a JMX file on this to load it in GUI mode
  • j meter-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

Note: the special name LAST can be used with jmeter-n.cmd, jmeter-t.cmd and jmeter-n-r.cmd and means the last test plan that was run interactively.

The environment variable JVM_ARGS can be used to override JVM settings in the jmeter.bat script. For example:

set JVM_ARGS=”-Xms1024m -Xmx1024m -Dpropname=propvalue”

j meter -t test.jmx …

Un*x script files; should work on most Linux/Unix systems:

  • j meter – run J Meter (in GUI mode by default). Defines some JVM settings which may not work for all JVMs.
  • j meter-server – start J Meter in server mode (calls jmeter script with appropriate parameters)
  • sh – very basic J Meter script with no JVM options specified.
  • mirror-server.sh – runs the J Meter Mirror Server in non-GUI mode
  • sh – Run the Shutdown client to stop a non-GUI instance gracefully
  • sh – Run the Shutdown client to stop a non-GUI instance abruptly

It may be necessary to edit the j meter shell script if some of the JVM options are not supported by the JVM you are using. The JVM_ARGS environment variable can be used to override or set additional JVM options, for example:

JVM_ARGS=”-Xms1024m -Xmx1024m” jmeter -t test.jmx [etc.]

will override the HEAP settings in the script.

JMeter’s Classpath

J Meter automatically finds classes from jars in the following directories:

  • J METER_HOME/lib – used for utility jars
  • J METER_HOME/lib/ext – used for JMeter components and plugins

If you have developed new J Meter components, then you should jar them and copy the jar into

J Meter’s lib/ext directory. J Meter will automatically find J Meter components in any jars found here.

Do not use lib/ext for utility jars or dependency jars used by the plugins; it is only intended for J Meter components and plugins.

If you don’t want to put J Meter plugin jars in the lib/ext directory, then define the property search_paths in jmeter.properties.

Utility and dependency jars (libraries etc) can be placed in the lib directory.

If you don’t want to put such jars in the lib directory, then define the property user.classpath or plugin_dependency_paths in j meter properties. See below for an explanation of the differences.

Other jars (such as JDBC, JMS implementations and any other support libraries needed by the J Meter code) should be placed in the lib directory – not the lib/ext directory, or added to user.classpath.

Note: J Meter will only find .jar files, not .zip.

You can also install utility Jar files in $JAVA_HOME/jre/lib/ext, or you can set the property user.classpath in jmeter.properties

Note that setting the CLASSPATH environment variable will have no effect. This is because J Meter is started with “java -jar”, and the java command silently ignores the CLASSPATH variable, and the -classpath/-cp options when -jar is used. [This occurs with all Java programs, not just J Meter.]

Using a HTTP(S) Test Script Recorder

If you are testing from behind a firewall/proxy server, you may need to provide J Meter with the firewall/proxy server hostname and port number. To do so, run the jmeter[.bat] file from a command line with the following parameters:

-H [proxy server hostname or ip address]

-P [proxy server port]

-N [nonproxy hosts] (e.g. *.apache.org|localhost)

-u [username for proxy authentication – if required]

-a [password for proxy authentication – if required]

Example : j meter -H my.proxy.server -P 8000 -u username -a password -N localhost

You can also use –proxyHost, –proxyPort, –username, and –password as parameter names

Parameters provided on a command-line may be visible to other users on the system.

If the proxy host and port are provided, then J Meter sets the following System properties:

  • proxyHost
  • proxyPort
  • proxyHost
  • proxyPort

If a nonproxy host list is provided, then J Meter sets the following System properties:

  • nonProxyHosts
  • nonProxyHosts

So if you don’t wish to set both http and https proxies, you can define the relevant properties in system.properties instead of using the command-line parameters.

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

J Meter also has its own in-built Proxy Server, the HTTP(S) Test Script Recorder . This is only used for recording HTTP or HTTPS browser sessions. This is not to be confused with the proxy settings described above, which is used when J Meter makes HTTP or HTTPS requests itself.

Non-GUI Mode (Command Line mode)

For non-interactive testing, you may choose to run J Meter without the GUI. To do so, use the following command options:

-n This specifies J Meter is to run in non-gui mode

-t [name of JMX file that contains the Test Plan].

-l [name of JTL file to log sample results to].

-j [name of J Meter run log file].

-r Run the test in the servers specified by the J Meter property “remote_hosts”

-R [list of remote servers] Run the test in the specified remote servers

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 -n -t my_test.jmx -l log.jtl -H my.proxy.server -P 8000

If the property jmeterengine.stopfail.system.exit is set to true (default is false), then J Meter will invoke System.exit(1) if it cannot stop all threads. Normally this is not necessary.

Full list of command-line options

Invoking J Meter as “jmeter -?” will print a list of all the command-line options. These are shown below.

-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 property file(s)

-t, –testfile {argument}

the jmeter test(.jmx) file to run

-j, –jmeterlogfile {argument}

the jmeter log file

-l, –logfile {argument}

the file to log samples to

-n, –nongui

run JMeter in nongui mode

-s, –server

run the JMeter server

-H, –proxyHost {argument}

Set a proxy server for JMeter to use

-P, –proxyPort {argument}

Set proxy server port for JMeter to use

-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 {filename}

a property file to be added as System properties

-L, –loglevel {argument}={value}

Define loglevel: [category=]level

e.g. jorphan=INFO or jmeter.util=DEBUG

-r, –runremote (non-GUI only)

Start remote servers (as defined by the jmeter property remote_hosts)

-R, –remotestart  server1,… (non-GUI only)

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)

Note: the JMeter log file name is formatted as a SimpleDateFormat (applied to the current date) if it contains paired single-quotes, .e.g. ‘jmeter_’yyyyMMddHHmmss’.log’

Test Your Software Testing Skills By Taking Our JMeter Practice Tests On This Link

Become Vskills Certified JMeter Tester. Learn the module “Installing and Running JMeter”. Try the free practice test!

Apply For JMeter Certification

Go back to Tutorial

JMeter Requirements
Building A Test Plan

Get industry recognized certification – Contact us

keyboard_arrow_up
Open chat
Need help?
Hello đŸ‘‹
Can we help you?