Step-by-Step Guide: How to Install JDK and Set Up Java Development Kit

Step-by-Step Guide: How to Install JDK and Set Up Java Development Kit Photo
Author: Tatyana Milkina

Welcome to the Page Dedicated to Installing JDK!

Here, you'll find a step-by-step guide for downloading, installing, and setting up the Java Development Kit (JDK) on your computer.

Java installation consists of five steps:

 

 

  1. Downloading the JDK package
  2. Installing JDK
  3. Adding the JAVA_HOME variable
  4. Updating the Path variable
  5. Verifying the correctness of the Java installation

1. Downloading the JDK Package

Start by downloading the JDK package. You can download it from the Oracle website. Oracle is the company that owns Java's rights. You can download any version on this page. At the time of writing this guide, the current version is Java 22, which we will download and install.

Choose your operating system—Linux, macOS, or Windows—and then select the file type for download:

Downloading the JDK Package


2. Installing JDK

After downloading the file, simply click on the downloaded .exe file and the following window will appear:

Starting the JDK Installation

From here, just click "Next" on almost all steps.

In the next step, you can choose a different directory for installation. By default, it’s set to C:\Program Files\Java:

Choosing an Installation Directory

I’ll leave it as it is, click "Next," and the installation process will begin. You’ll see a status window showing the copying of new files, and finally, it’s almost done:

Completing the Installation

Click "Close" to finish the installation. But there’s still more to do.


3. Adding the JAVA_HOME Variable

Next, we need to set up the JAVA_HOME system variable. One way to do this is to search for "Edit the system environment variables":

Searching for Environment Variable Settings

Go to the Environment Variables section:

Environment Variables Section

In the system variables section, click "New" to create a new variable:

Creating a New Variable

Enter the variable name JAVA_HOME in uppercase with underscores, and in the value field, specify the path to your Java directory, e.g., C:\Program Files\Java\jdk-22:

Setting JAVA_HOME

Click "OK."


4. Updating the Path Variable

Another necessary step is to update the Path variable. In the list of environment variables, find Path and click "Edit":

Editing the Path Variable

Carefully, without removing anything, click "New":

Adding a New Path Entry

Add the line %JAVA_HOME%\bin and click "OK". It’s recommended to move the newly added line to the top:

Adding %JAVA_HOME%\bin

 

5. Verifying the Correctness of the Java Installation

Finally, let’s check if Java is installed correctly. Open the Command Prompt by typing cmd in the search bar.

In the Command Prompt, type the following command:

java -version

If everything is fine, you will see the installed version of Java displayed:

Verifying Java Version

Now, the Java installation is complete, and you can start writing Java programs.

Курс 'Java для начинающих' на Udemy Курс 'Java для начинающих' на Udemy
Read also:
Comments