In the following sections we describe the installation of Java Development Kit (JDK) and JMeter. We use the JMeter executable to start JMeter.
Note
Readers who are already familiar with JMeter setup can start directly with the first chapter.
MacOSX
The following section explains how to install Java and JMeter on MacOSX. If you are using Windows or Linux, skip to the appropriate section.
Download JDK
Download the Java Development Kit (JDK) from Oracle’s web site.1
JMeter requires Java Runtime Environment (JRE) to run. But for some of the advanced uses, we recommend installing a complete development environment. Pick the latest JDK version for MacOSX. This is usually found on the web page by name (jdk-8u60-macosx-x64.dmg). Double-click it and follow the instructions on the screen (see Figures 13-1 and 13-2).
Figure 13-1. Launch the installer
Figure 13-2. Accept the installer defaults to install JDK
Install JDK
Follow the instructions and complete the installation . To verify the installation of the Java runtime, run the following command in the terminal window.
$ java -version
java version "1.8.0_60" Java(TM)
SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
Set Up the Environment Variable
To set the JAVA_HOME environment variable, run the following commands in the terminal window.
Open ∼/.bash_profile in your favorite editor.
$ vim ∼/.bash_profile
Or
$ vim ∼/.profile
Add the following line to the file:
export JAVA_HOME=$(/usr/libexec/java_home)
Log out from the current terminal window and open a new terminal window to pick up the new changes. Or, you can run the following command in the current terminal window.
$ source ∼/.bash_profile or source ∼/.profile
Issue the following command to verify that JAVA_HOME has been set under the environment variables .
$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home
Issue the following command to verify that JDK has been installed properly and you have Performance Dashboard environment variable. (This verifies the Java compiler.)
$ javac -version
javac 1.8.0_60
Download JMeter
Download JMeter from the Apache web site.2
Pick the latest version of JMeter; as of now, the latest JMeter available is apache-jmeter-3.0.tgz.
Set Up JMeter
Setting up JMeter just involves extracting the JMeter binaries into the user-defined location on the user machine. Assuming the downloaded JMeter binaries are in your Downloads folder, run the following command in the terminal window.
$ tar -xf ∼/Downloads/apache-jmeter-3.0.tgz -C /usr/local/
Issue the following command in your terminal window to verify that you have extracted the JMeter binaries correctly.
$ cd /usr/local/apache-jmeter-3.0/
$ ls -1p
LICENSE
NOTICE
README
bin/
docs/
extras/
lib/
licenses/
printable_docs/
It is good practice to set up the JMETER_HOME environment variable and add the following lines to the PATH.
Open ∼/.bash_profile or ∼/.profile to your favorite editor.
$ vim ∼/.bash_profile
Or
$ vim ∼/.profile
And add the following lines.
export JMETER_HOME="/usr/local/apache-jmeter-3.0"
export PATH="$PATH:$JMETER_HOME/bin"
Log out from the current terminal window and open a new terminal window to pick up the changes. Or you can run the following command in the current terminal window.
$ source ∼/.bash_profile or source ∼/.profile
Now that you have set up JMeter, you can start JMeter by running the startup script.
Run the following command in the terminal window (see Figure 13-3).
Figure 13-3. JMeter GUI
$ jmeter
Windows
The following section shows you how to install Java and JMeter on Windows 7. If you are using MacOSX or Linux, skip to the appropriate section.
Download JDK
Download the Java Development Kit (JDK) from Oracle’s web site.3
JMeter requires just the Java Runtime Environment (JRE) to run. But for some of the advanced uses, we recommend installing a complete development environment. Pick the latest JDK for Windows. This is usually found on the web page by name. They are called jdk-8u60-windows-x64.exe for 64-bit and jdk-8u60windows-i586.exe for 32-bit. Depending on your machine configuration, download the required JDK.
Install JDK
Double-click the executable to launch the installer and follow the instructions (see Figures 13-4, 13-5, and 13-6).
Figure 13-4. Installer step 1
Figure 13-5. Installer step 2
Figure 13-6. Installer step 3
To verify the installation of Java runtime , run the following command on the Windows command prompt.
C:> java -version
java version "1.8.0_60" Java(TM)
SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
C:>
Set Up the Environment Variable
To set the JAVA_HOME environment variable , run the following commands on the Windows command prompt.
C:> setx JAVA_HOME "C:Program FilesJavajdk1.8.0_60"
C:> setx PATH "%PATH%;%JAVA_HOME%in";
Close the Windows command prompt.
Issue the following command to verify that JAVA_HOME has been set under the environment variables.
C:> echo %JAVA_HOME%
C:Program FilesJavajdk1.8.0_60
Issue the following command to verify that JDK has been installed properly and you have set the correct environment variable. (This verifies the Java compiler.)
C:> javac -version
javac 1.8.0_60
Download JMeter
Download JMeter from the Apache web site.4
Pick the latest version of JMeter; as of the writing of this book, the latest JMeter available is apachejmeter-3.0.zip.
Set Up JMeter
Setting up JMeter involves extracting the JMeter binaries at a user-defined location. Navigate to your Downloads folder where you have downloaded the binaries, right-click the file, choose Extract All, and then follow the instructions on the screen.
Once the extraction is complete, navigate to the JMeter folder to see the contents. The results will resemble Figure 13-7.
Figure 13-7. JMeter contents
It is a good practice to set up the JMETER_HOME environment variable and add this into the PATH.
C:> setx JMETER_HOME "C:apache-jmeter-3.0"
C:> setx PATH "%PATH%;%JMETER_HOME%in";
To start Jmeter, run the following command on your Windows command prompt.
C:> cd C:apache-jmeter-3.0in
C:apache-jmeter-3.0in> jmeter.bat
You will see something similar to Figure 13-8.
Figure 13-8. JMeter GUI
Linux
The following section explains how to install Java and JMeter on Linux. If you are using MacOSX or Windows, skip to the appropriate section.
Install JDK
On Fedora, Oracle Linux , and Red Hat Enterprise Linux, open the terminal window and issue the following command.
$ su -c "yum install java-1.8.0-openjdk"
Open JDK Java 8 was released in March 2014 and has been made into official Ubuntu repositories for 14.10 Utopic and higher. For Ubuntu 14.04, Ubuntu 12.04, and Linux Mint 17, you have to install it from PPA. It’s available in Ubuntu Software Center for Ubuntu 14.10 and Ubuntu 15.04.
Open the terminal window in Ubuntu and issue the following command.
$ sudo add-apt-repository ppa:openjdk-r/ppa
$ sudo apt-get update
$ sudo apt-get install openjdk-8-jdk
For more information on JDK installation, check the JDK installation web site.5
To verify the installation of Java runtime , run the following command in the terminal window.
$ java -version
openjdk version "1.8.0_45-internal"
OpenJDK Runtime Environment (build 1.8.0_45-internal-b14)
OpenJDK 64-Bit Server VM (build 25.45-b02, mixed mode)
Set Up the Environment Variable
To set the JAVA_HOME environment variable, run the following commands in the terminal window.
Open ∼/.bashrc in your favorite editor.
$ gedit ∼/.bashrc
Add the following lines.
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-adm64
PATH=$PATH:$JAVA_HOME/bin
Log out from the current terminal window and open a new terminal window to pick up the changes. Or you can run the following command in the current terminal window.
$ source ∼/.bashrc
Issue the following command to verify that JAVA_HOME has been set under the environment variables.
$ echo $JAVA_HOME
/usr/lib/jvm/java-8-openjdk-adm64
Issue the following command to verify that JDK has been installed properly and you have set the correct environment variable. (This verifies the Java compiler.)
$ javac -version
javac 1.8.0_45-internal
Download JMeter
Download JMeter from the Apache web site.6
Pick the latest version of JMeter; as of the writing of this book, the latest JMeter available is apachejmeter-3.0.tgz.
Set Up JMeter
Setting up JMeter just involves extracting the JMeter binaries at a user-defined location. Assuming the downloaded JMeter binaries are in your Downloads folder, run the following command in the terminal window.
$ sudo tar -xf ∼/Downloads/apache-jmeter-3.0.tgz -C /usr/ local/
Issue the following command in your terminal window to verify that you have extracted JMeter binaries correctly.
$ cd /usr/local/apache-jmeter-3.0/
$ ls -1p
bin/
docs/
extras/
lib/
LICENSE
licenses/
NOTICE
printable_docs/
README
It is good practice to set up the JMETER_HOME environment variable and add this into the PATH.
Open ∼/.bashrc in your favorite editor and add the following lines.
$ gedit ∼/.bashrc
Add the following lines.
export JMETER_HOME="/usr/local/apache-jmeter-3.0"
export PATH=$PATH:$JMETER_HOME/bin
Log out from the current terminal window and open a new terminal window to pick up the changes. Or you can run the following command in the current terminal window.
$ source ∼/.bashrc
Now that you have set up JMeter, you can start JMeter by running the JMeter startup script.
Run the following command in the terminal window (see Figure 13-9).
Figure 13-9. JMeter GUI Ubuntu
$ jmeter
Note
Going forward, we use Windows-based examples, but you can use the same steps on MacOS or any Linux OS.