Mac Set Environment Variable For Java

  • Related Questions & Answers
  • Selected Reading

Setting environment variables. For the tcsh shell, the format for setting an environment variable is setenv KEY value. The following is an example which will set the JAVAHOME variable to /Library/Java/Home. Follow this easy step by step tutorial to learn how to set environment variables in mac through the terminal. Environment variables are the piece of informat. Locate your Java installation directory. If you didn't change the path during installation, it'll be.

Once you have installed JDK version on your windows machine, you have to set up Environment Variables.

Please find below steps to set the java path

Go to My Computer ---> Right Click on it ---> Advanced System Settings ---> Advanced Tab ---> Click on Environment Variables

  • Now you have to alter the “Path” variable under system variables such that it contains a path to Java Environment. Select the path variable and click on the “Edit” button
  • By default, Java is installed in “C:Program FilesJavajre versionbin” in case you have changed the location of installation, then add that path
  • Click on OK button and now to check if the installation is done correctly or not, open command prompt and type “java -version“
  • You can see that Java is running on your machine. In order to make sure whether the compiler is setup, type javac in command prompt. You will see a list related to javac.
Mac set environment variable for java programming
  • EasyMock Basics Tutorial
  • EasyMock Resources
  • Selected Reading

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

System Requirement

JDK1.5 or above.
Memoryno minimum requirement.
Disk Spaceno minimum requirement.
Operating Systemno minimum requirement.

Step 1: Verify Java Installation on Your Machine

Windows

Open the console and execute the following java command.

OSTaskCommand
WindowsOpen Command Consolec:> java -version
LinuxOpen Command Terminal$ java -version
MacOpen Terminalmachine:~ joseph$ java -version

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

OSOutput
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, To install the Java Software Development Kit (SDK) click here.

We assume you have Java 1.6.0_21 installed on your system 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,

OSOutput
WindowsSet the environment variable JAVA_HOME to C:Program FilesJavajdk1.6.0_21
Linuxexport JAVA_HOME=/usr/local/java-current
Macexport JAVA_HOME=/Library/Java/Home

Append the location of the Java compiler to your System Path.

OSOutput
WindowsAppend the string ;C:Program FilesJavajdk1.6.0_21bin to the end of the system variable, Path.
Linuxexport PATH=$PATH:$JAVA_HOME/bin/
Macnot required

Set Java Path In Environment Variable

Verify Java Installation using the command java -version as explained above.

Mac Set Environment Variable For Java

Step 3: Download EasyMock Archive

Variable

To download the latest version of EasyMock click here.

How To Set Environment Variable For Java In Mac Os X

Environment

Save the zip folder on your C drive, let's say, C:>EasyMock.

OSArchive name
Windowseasymock-3.2.zip
Linuxeasymock-3.2.zip
Maceasymock-3.2.zip

Step 4: Download EasyMock Dependencies

Download the latest version of cglib jar file from https://github.com/cglib/cglib/releases and copy it onto C:>EasyMock folder. At the time of writing this tutorial, the latest version was 3.1.

Download the latest version of objenesis zip file from http://objenesis.org/download.html and copy it onto C:>EasyMock folder. At the time of writing this tutorial, the latest version was 2.1. 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. The following table shows how to set the environment variable on different operating systems, assuming we've extracted easymock-3.2.jar, cglib-3.1.jar, and objenesis-2.1.jar onto C:>EasyMock folder.

OSOutput
WindowsSet the environment variable EasyMock_HOME to C:EasyMock
Linuxexport EasyMock_HOME=/usr/local/EasyMock
Macexport EasyMock_HOME=/Library/EasyMock

Step 6: Set CLASSPATH Variable

Set the CLASSPATH environment variable to point to the location where EasyMock and dependency jars are stored. The following table shows how to set the CLASSPATH variable on different operating systems.

OSOutput
WindowsSet the environment variable CLASSPATH to %CLASSPATH%;%EasyMock_HOME%easymock-3.2.jar;%EasyMock_HOME%cglib-3.1.jar;%EasyMock_HOME%objenesis-2.1.jar;.;
Linuxexport CLASSPATH=$CLASSPATH:$EasyMock_HOME/easymock-3.2.jar:$EasyMock_HOME/cglib-3.1.jar:$EasyMock_HOME/objenesis-2.1.jar:.
Macexport CLASSPATH=$CLASSPATH:$EasyMock_HOME/easymock-3.2.jar:$EasyMock_HOME/cglib-3.1.jar:$EasyMock_HOME/objenesis-2.1.jar:.

Step 7: Download JUnit Archive

Download the latest version of JUnit jar file from Github. Save the folder at the location C:>Junit.

OSArchive name
Windowsjunit4.11.jar, hamcrest-core-1.2.1.jar
Linuxjunit4.11.jar, hamcrest-core-1.2.1.jar
Macjunit4.11.jar, hamcrest-core-1.2.1.jar

Step 8: Set JUnit Environment

Set the JUNIT_HOME environment variable to point to the base directory location where JUnit jars are stored on your machine. The following table shows how to set this environment variable on different operating systems, assuming we've stored junit4.11.jar and hamcrest-core-1.2.1.jar at C:>Junit.

OSOutput
WindowsSet the environment variable JUNIT_HOME to C:JUNIT
Linuxexport JUNIT_HOME=/usr/local/JUNIT
Macexport JUNIT_HOME=/Library/JUNIT

Mac Set Java Path

Step 9: Set CLASSPATH Variable

Mac Set Environment Variable For Java Home

Set the CLASSPATH environment variable to point to the JUNIT jar location. The following table shows how it is done on different operating systems.

OSOutput
WindowsSet the environment variable CLASSPATH to %CLASSPATH%;%JUNIT_HOME%junit4.11.jar;%JUNIT_HOME%hamcrest-core-1.2.1.jar;.;
Linuxexport CLASSPATH=$CLASSPATH:$JUNIT_HOME/junit4.11.jar:$JUNIT_HOME/hamcrest-core-1.2.1.jar:.
Macexport CLASSPATH=$CLASSPATH:$JUNIT_HOME/junit4.11.jar:$JUNIT_HOME/hamcrest-core-1.2.1.jar:.