EasyMock - Environment Setup



EasyMock is a framework for Java, so the very first requirement is to have JDK installed in your machine.

System Requirement

JDK 1.5 or above.
Memory no minimum requirement.
Disk Space no minimum requirement.
Operating System no minimum requirement.

Step 1 - verify Java installation in your machine

Now open console and execute the following java command.

OS Task Command
Windows Open Command Console c:\> java -version
Linux Open Command Terminal $ java -version
Mac Open Terminal machine:~ joseph$ java -version

Let's verify the output for all the operating systems:

OS Output
Windows java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b07)
Java HotSpot(TM) Client VM (build 17.0-b17, mixed mode, sharing)
Linux java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b07)
Java HotSpot(TM) Client VM (build 17.0-b17, mixed mode, sharing)
Mac java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b07)
Java HotSpot(TM)64-Bit Server VM (build 17.0-b17, mixed mode, sharing)

If you do not have Java installed, install the Java Software Development Kit (SDK) from http://www.oracle.com/technetwork/java/javase/downloads/index.html. We are assuming Java 1.6.0_21 as installed version for this tutorial.

Step 2: Set JAVA environment

Set the JAVA_HOME environment variable to point to the base directory location where Java is installed on your machine. For example

OS Output
Windows Set the environment variable JAVA_HOME to C:\Program Files\Java\jdk1.6.0_21
Linux export JAVA_HOME=/usr/local/java-current
Mac export JAVA_HOME=/Library/Java/Home

Append Java compiler location to System Path.

OS Output
Windows Append the string ;C:\Program Files\Java\jdk1.6.0_21\bin to the end of the system variable, Path.
Linux export PATH=$PATH:$JAVA_HOME/bin/
Mac not required

Verify Java Installation using java -version command explained above.

Step 3: Download EasyMock archive

Download latest version of EasyMock zip file from http://sourceforge.net/projects/easymock/files/EasyMock/3.2/easymock-3.2.zip/download. At the time of writing this tutorial, I downloaded easymock-3.2.zip and copied it into C:\>EasyMock folder.

OS Archive name
Windows easymock-3.2.zip
Linux easymock-3.2.zip
Mac easymock-3.2.zip

Step 4: Download EasyMock dependencies

Download latest version of cglib jar file from https://github.com/cglib/cglib/releases. At the time of writing this tutorial, I downloaded cglib-3.1.jar and copied it into C:\>EasyMock folder.

Download latest version of objenesis zip file from http://objenesis.org/download.html. At the time of writing this tutorial, I downloaded objenesis-2.1-bin.zip and copied it into C:\>EasyMock folder. Extract objenesis-2.1.jar to C:\>EasyMock folder

Step 5: Set EasyMock environment

Set the EasyMock_HOME environment variable to point to the base directory location where EasyMock and dependency jars are stored on your machine. Assuming, we've extracted easymock-3.2.jar, cglib-3.1.jar and objenesis-2.1.jar in EasyMock folder on various Operating Systems as follows.

OS Output
Windows Set the environment variable EasyMock_HOME to C:\EasyMock
Linux export EasyMock_HOME=/usr/local/EasyMock
Mac export EasyMock_HOME=/Library/EasyMock

Step 5: Set CLASSPATH variable

Set the CLASSPATH environment variable to point to the EasyMock and dependency jars location. Assuming, we've stored easymock-3.2.jar, cglib-3.1.jar and objenesis-2.1.jar in EasyMock folder on various Operating Systems as follows.

OS Output
Windows Set the environment variable CLASSPATH to %CLASSPATH%;%EasyMock_HOME%\easymock-3.2.jar;%EasyMock_HOME%\cglib-3.1.jar;%EasyMock_HOME%\objenesis-2.1.jar;.;
Linux export CLASSPATH=$CLASSPATH:$EasyMock_HOME/easymock-3.2.jar:$EasyMock_HOME/cglib-3.1.jar:$EasyMock_HOME/objenesis-2.1.jar:.
Mac export CLASSPATH=$CLASSPATH:$EasyMock_HOME/easymock-3.2.jar:$EasyMock_HOME/cglib-3.1.jar:$EasyMock_HOME/objenesis-2.1.jar:.

Step 6: Download Junit archive

Download latest version of JUnit jar file from https://github.com/junit-team/junit/wiki/Download-and-Install. At the time of writing this tutorial, I downloaded Junit-4.11.jar,hamcrest-core-1.2.1.jar and copied them into C:\>JUnit folder.

OS Archive name
Windows junit4.11.jar, hamcrest-core-1.2.1.jar
Linux junit4.11.jar, hamcrest-core-1.2.1.jar
Mac junit4.11.jar, hamcrest-core-1.2.1.jar

Step 7: Set JUnit environment

Set the JUNIT_HOME environment variable to point to the base directory location where JUNIT jars are stored on your machine. Assuming, we've stored junit4.11.jar, hamcrest-core-1.2.1.jar in JUNIT folder on various Operating Systems as follows.

OS Output
Windows Set the environment variable JUNIT_HOME to C:\JUNIT
Linux export JUNIT_HOME=/usr/local/JUNIT
Mac export JUNIT_HOME=/Library/JUNIT

Step 8: Set CLASSPATH variable

Set the CLASSPATH environment variable to point to the JUNIT jar location. Assuming, we've stored junit4.10.jar in JUNIT folder on various Operating Systems as follows.

OS Output
Windows Set the environment variable CLASSPATH to %CLASSPATH%;%JUNIT_HOME%\junit4.11.jar;%JUNIT_HOME%\hamcrest-core-1.2.1.jar;.;
Linux export CLASSPATH=$CLASSPATH:$JUNIT_HOME/junit4.11.jar:$JUNIT_HOME/hamcrest-core-1.2.1.jar:.
Mac export CLASSPATH=$CLASSPATH:$JUNIT_HOME/junit4.11.jar:$JUNIT_HOME/hamcrest-core-1.2.1.jar:.
Advertisements