Setting up the Java Development Kit (JDK)
The Java Development Kit (JDK) is a software development kit required to build and run Java applications. It includes essential components such as the Java compiler (javac
), the Java Runtime Environment (JRE), and various development and debugging tools.
There are two main types of JDKs commonly used:
- Oracle JDK – Officially provided by Oracle, includes enterprise-grade features.
- OpenJDK – An open-source implementation of the Java Platform, Standard Edition, widely used and supported by the community.
Steps to Set Up Oracle JDK
-
Download the Oracle JDK Visit the official Oracle JDK Downloads page and download the version suitable for your operating system.
-
Install the JDK
Run the installer and follow the setup instructions. -
Set Environment Variables
- Add the JDK
bin
directory to the systemPATH
variable. - Set
JAVA_HOME
to the JDK installation directory (e.g.,C:\Program Files\Java\jdk-21
).
- Add the JDK
-
Verify Installation
Open a terminal or command prompt and run:java -version javac -version
Steps to Set Up OpenJDK
OpenJDK provides the same core functionality as Oracle JDK and is widely used in Linux distributions and open-source projects.
For Windows:
-
Download OpenJDK
Use trusted providers such as: -
Install or Extract
Extract the ZIP file or run the MSI installer. -
Set Environment Variables
- Set
JAVA_HOME
to the JDK directory. - Add
%JAVA_HOME%\bin
to thePATH
.
- Set
-
Verify Installation
java -version javac -version
For Linux/macOS:
Install via a package manager:
- Ubuntu/Debian:
sudo apt install openjdk-21-jdk
- Fedora:
sudo dnf install java-21-openjdk
- macOS (Homebrew):
brew install openjdk@21
Set JAVA_HOME
and update PATH
in your shell config file.