Setting Up Java Development Environment

How to install Java?

In this tutorial, we will go through the steps to prepare your local machine for Java development.

1. Install Java Development Kit (JDK)

  1. Go to this page on Oracle website → Java SE Downloads
  2. Click on JDK Download
    At the top of the page, you have the latest version of the JDK, if you scroll down you will see the older versions, choose whichever version suits you best.
  3. Choose Windows x64 Installer (.exe) for Windows or macOS Installer for MAC OS
  4. When the download is complete, find the JDK .exe program in your Downloads folder and run it.
    Installation is very simple, just follow the instructions and it should be very easy to install.
    Remember where you installed Java, usually, it is at C:\Program Files\Java


2. Set JAVA_HOME

2.1. Setting up path for Windows 10

Assuming that you have installed Java in C:\Program files\Java\JDK directory.

2.2. Set JAVA_HOME environment variable

Open Advanced System Settings

  1. In Windows Search Box type in advanced system settings
  2. It should appear in the Best match, just click on it
advanced system settings windows10

    3. Click on Environment Variables
    
4. Under System variables click the New button and enter JAVA_HOME as Variable name and the path to your Java JDK directory under Variable value.

set java_home variable


2.3. Update System PATH

  1. In Environment Variables window under System variables select Path variable
  2. Click on Edit
  3.  In Edit environment variable window click New
  4. Type in %JAVA_HOME%\bin
  5. Click OK
java update system path variable


Let’s test it

Open a command prompt, and type in:
java -version and after that type in
javac -version

You should see the output like this one:

javac version java version


3. Setting up path for MAC OS

For MAC OS, it’s very simple, just open a new Terminal window and type in:

export JAVA_HOME=/usr/libexec/java_home

and you should be good to go.

That’s it!

 

Leave a Reply

Your email address will not be published.