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)
- Go to this page on Oracle website → Java SE Downloads
- 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.
- Choose Windows x64 Installer (.exe) for Windows or macOS Installer for MAC OS
- 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
- In Windows Search Box type in advanced system settings
- It should appear in the Best match, just click on it
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.
2.3. Update System PATH
- In Environment Variables window under System variables select Path variable
- Click on Edit
- In Edit environment variable window click New
- Type in %JAVA_HOME%\bin
- Click OK
Let’s test it
Open a command prompt, and type in:
java -version and after that type in
You should see the output like this one:
3. Setting up path for MAC OS
For MAC OS, it’s very simple, just open a new Terminal window and type in:
and you should be good to go.That’s it!