Summary: in this tutorial, you will learn how to install JDK on your computer to write, compile, and run Java applications.
The Java Development Kit (JDK) is a software development kit that allows you to develop Java applications.
JDK includes tools and libraries necessary for Java development:
- Java Compiler (javac).
- Java Virtual Machine (java).
- Other utility tools
The JDK allows you to write, compile, and run Java applications. It’s required to install JDK before writing the first Java application.
To install JDK on your computer, you follow these steps:
Step 1. Download JDK
- Visit the official Oracle JDK download page.
- Download the installer for your operating systems (Windows, macOS, or Linux)
Step 2. Install JDK on Windows
On Windows, you usually install the JDK via an executable installer:
- Double-click the downloaded install file to start the installation.
- Follow the on-screen instructions to complete the installation. Note that you might be asked to choose the installation directory. You can stick with the default.
- Once the installation is complete, you can set up the
JAVA_HOME
environment variable.- Open the System Property window by pressing the
Windows + R
keys to open the Run dialogue box, typesysdm.cpl
in the box, and pressEnter
. - Click the Advanced Tab and the Environment Variables button.
- Under System Variables click New… button and set the variable name
JAVA_HOME
to the installation path of your JDK e.g., (C:\Program Files\Java\jdk-20
)
- Open the System Property window by pressing the
- Add JDK’s bin directory to the system
PATH
:- Under System variables, find the path variable and click the Edit… button.
- Click the New button and add the path to the
bin
directory of your JDK e.g.,C:\Program Files\Java\jdk-20\bin
- Click the OK button to close the Environment Variables dialog.
Step 3. Verify installation
Open the Command Prompt or Powershell and type the following command to verify the installation:
java -version
It should display the installed Java version.