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 the 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. On Windows, it is 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. Click on it.
3. Click on Environment Variables,
4. Under System variables click the New button and enter JAVA_HOME as the Variable name and the path to your Java JDK directory under Variable value.
2.3. Update System PATH
- In the Environment Variables window under System variables, select Path variable,
- Click on Edit,
- In the Edit environment variable window, click New,
- Type in %JAVA_HOME%\bin
- Click OK
Trying if Java Works
Open a command prompt, and type the following command.
You can also try executing the following command:
You should see the following output.
3. Setting up Path on MAC OS
To learn how to configure JAVA_HOME on a Mac computer, read How to Set JAVA_HOME on Mac.