How to Install Java JDK on Windows
Introduction
Java Development Kit (JDK) is an essential tool for anyone looking to develop Java applications. Installing the JDK on a Windows machine is a straightforward process, and while specific versions may vary, the installation steps are generally the same across different versions of the JDK. This guide will walk you through the process of downloading, installing, and configuring the JDK on a Windows system.
Step 1: Download the JDK
To begin, you need to download the appropriate version of the Java JDK for your system. Visit the official Oracle website or other reliable sources like OpenJDK to find the JDK downloads.
- Go to the download page
Navigate to the Oracle JDK downloads page or OpenJDK. - Select the version
Choose the version of the JDK you need. You may find multiple versions (e.g., JDK 8, JDK 17, JDK 23). For most purposes, the latest Long-Term Support (LTS) version is a safe choice, but you can install any version based on your project needs. - Choose the right download for your system
- Windows x64 Installer
This is for most modern computers with 64-bit processors. - Windows x86 Installer
If your system is older and runs on a 32-bit processor, choose this option. - Windows ARM Installer
For devices with ARM processors, such as certain newer laptops or tablets, download the ARM version.
- Windows x64 Installer
Step 2: Install the JDK
Once the download is complete, follow these steps to install the JDK:
- Run the installer
Locate the downloaded file (usually in your “Downloads” folder) and double-click it to start the installation process. - Accept the license agreement
You’ll be prompted to review and accept the license agreement before proceeding with the installation. - Select installation directory
By default, the JDK will install inC:\Program Files\Java\jdk-<your version>
. You can change this location if needed, but it’s recommended to use the default unless you have specific requirements. - Complete the installation
Once the installation is complete, clickClose
to exit the setup wizard.
Once the installation is complete, you should see a confirmation message. The JDK is now installed, but you’ll need to configure your system’s environment variables before you can start using Java from the command line.
Step 3: Set Up Environment Variables
To ensure that Java can be run from the command line and that tools like javac (the Java compiler) are available, you need to set up the PATH and JAVA_HOME environment variables.
- Open Environment Variables Settings:
- Right-click on
This PC
orComputer
on your desktop or in File Explorer and selectProperties
. - Click on
Advanced system settings
on the left side of the window. - Click on the
Environment Variables
button.
- Right-click on
- Set JAVA_HOME Variable:
- In the
System variables
section, clickNew
. - Enter
JAVA_HOME
as the variable name. - Set the variable value to the path of your JDK installation directory
C:\Program Files\Java\jdk-<your version>
, (e.g.,C:\Program Files\Java\jdk-21
). - Click
OK
to save.
- In the
- Update the PATH Variable:
- In the
System variables
section, select thePath
variable and clickEdit
. - Click
New
and add the path to the JDKbin
directory (e.g.,C:\Program Files\Java\jdk-21\bin
). - Click
OK
to save the changes.
- In the
Step 4: Verify the Installation
To verify that Java is installed correctly, open the Command Prompt and type the following commands:
1
java -version
You should see output that displays the version of Java you installed. Similarly, you can check if the Java compiler is available by typing:
1
javac -version
If both commands return the expected version numbers, your installation is successful.
Conclusion
Installing the Java JDK on Windows is a fairly straightforward process. While different versions of the JDK may be available, the installation steps remain largely the same. After installation, configuring environment variables like JAVA_HOME and updating your Path ensures that Java can be run from any command line prompt. With the JDK properly set up, you’re ready to start developing Java applications!