Mac Set Environment Variable For Java

admin 12/13/2021

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. Setup Java Path on Windows 10. Open Start menu and search for Advanced System Settings. Launch View advanced system settings: Go to Environment Variables. Add new system variable with a name JAVAHOME and value – your path to Java, in my case, it’s C:Program FilesJavajre-9.0.4. Set the EasyMockHOME 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.

In order to run Java application you need to have first installed Java on your Mac or Windows laptop or desktop.

It’s absolutely required to complete Java setup right way for your production & development applications. If you are a first time Java user then first step is to go to official Oracle website and download JDK.

Below detailed steps will help also if you have below questions:

  • How to fix JAVA_HOME error while starting Tomcat Server?
  • Why i’m getting jre_home is not defined correctly tomcat error?
  • How to set jre_home environment variable?
  • jre_home on windows
  • Difference between java_home vs jre_home
  • How to set jre_home via command line?

In this tutorial we will discuss how to install Java, setup JRE_HOME & JAVA_HOME environment variables on Windows platform only. For Mac and Linux, I’ll publish another tutorial with all detailed steps later.

How to set environment variable for java in mac os x

Let’s get started

  1. Locate your Java installation directory. If you didn't change the path during installation, it'll be.
  2. 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.


Configure JAVA_HOME / JRE_HOME Environment Variables

  • Go to official Oracle site and Download JDK binary
  • Click on Java Download
  • Accept License Agreement
  • Download binary next to Windows x64


  • Double click on .exe file and it will install JDK and JRE both on your Windows Laptop/Desktop
  • By default it will install JDK and JRE at location: C:Program FilesJava folder


  • Now minimize all windows and you will see Desktop icon (check this screenshot)
  • Right click on it
  • Click on Properties
  • Click on Advanced System Settings link as you in above diagram


  • Click on Advanced Tab
  • Click on Environment Variables... button


Set Environment Variables On Mac

  • New Pop-up Window will appear
  • Click on New…
  • Enter JAVA_HOME as variable name and C:Program FilesJavajdk1.8.0_121 as Value
  • Enter JRE_HOME as variable name and C:Program FilesJavajre1.8.0_121 as Value
  • Click OK button
  • Exit System Properties window

At this time, you are all set.

How to verify?

How to verify if JAVA_HOME and JRE_HOME environment variables setup correctly or not?

  • Just open command prompt
  • Type java -version
  • It will print installed Java details as shown below

That’s it. Let me know if you face any issue installing Java on your laptop. Make sure to update Java version number as per your installation in above steps. Happy coding and happy open sourcing.

How To Set Environment Variable For Java In Mac Os X

What is a difference Between JRE and JDK?

Ideally JRE provides runtime environment for your application. While running your development or production environment, you just need JRE.

Java Set Environment Variables

On other end, while you are developing Java application, JDK provides more debugging and development functionalities which wont part of JRE.

Mac Set Environment Variable For Java Jdk

Join the Discussion

Mac Set Environment Variable For Java Programming

If you liked this article, then please share it on social media or leave us your comments. Limited time 3 months free WPEngine hosting.

Mac Set Environment Variable Java_home

Other Popular Articles...