To download and install the Java Development Kit ( JDK) and Java Runtime Environment (JRE), follow these step-by-step instructions for Windows, macOS, and Linux.The overall process is similar across all platforms, with minor differences in installation steps and setting up environment variables.
✅What is JDK in Java?
The Java Development Kit (JDK) is a complete software development kit used to build Java applications. It includes:
- Java Runtime Environment (JRE) – provides the libraries and tools to run Java programs.
- Java Virtual Machine (JVM) – executes the compiled Java bytecode.
- Development tools – such as the Java compiler (
javac
), debugger, and packaging utilities.
In short, the JDK is more than just a runtime environment—it provides everything needed to develop, compile, and run Java programs.
✅Why Do We Need JDK Instead of Just JRE?
A common question developers ask is:
👉 “To run Java programs, isn’t the JRE enough? Why do we need the complete JDK?”
The answer:
- The JRE is enough to run Java applications.
- But to develop Java applications, you need tools like the compiler (
javac
), debugger, and other utilities that are only included in the JDK.
That’s why programmers use the JDK for development and the JRE for execution.
✅The Architecture of JDK in Java

The architecture of JDK consists of three essential components:
- JVM (Java Virtual Machine)
- Provides a runtime environment for Java programs.
- Converts compiled Java bytecode into machine code.
- Powers Java’s famous feature: “Write once, run anywhere.”
- JRE (Java Runtime Environment)
- Provides the core libraries, Java ClassLoader, and other components required to run applications.
- It does not include development tools like the compiler.
- Development Tools (inside JDK)
- Includes
javac
(Java compiler),jdb
(debugger),jar
(archiver), and other utilities required for building Java applications.
- Includes
✅Downloading Java JDK and JRE
1. Visit the Official Website
Go to the Oracle Java Downloads page or the OpenJDK official site. The current stable Java versions are JDK 21 (LTS) and JDK 23 (latest release).
2. Choose Your Operating System
Download the installer that matches your operating system:
- Windows (.exe)
- macOS (.dmg or .pkg)
- Linux (.tar.gz or Debian package)
3. Accept the License Agreement
For Oracle JDK downloads, review and accept the license agreement before proceeding with the download.
✅ Installing Java JDK on Windows
1. Run the Installer
Double-click the downloaded .exe
file to start the installation.
2. Follow Installation Prompts
Proceed with the setup wizard, selecting the default options unless you prefer a custom location. By default, Java is installed in:
C:\Program Files\Java\jdk-xx
3. Set the JAVA_HOME Environment Variable
- Right-click This PC → Properties → Advanced system settings → Environment Variables.
- Add a new variable:
- Name:
JAVA_HOME
- Value: path of your JDK installation (e.g.,
C:\Program Files\Java\jdk-21
).
- Name:
- Edit the existing Path variable and add:
%JAVA_HOME%\bin
👉Follow this detailed guide on how to set up the Java PATH environment variable
4. Verify Installation
Open Command Prompt and run:
java --version
javac --version
📌If both commands show the installed version, your Java JDK setup on Windows is complete.
✅ Installing Java JDK on macOS
1. Run the Installer
Open the downloaded .dmg
or .pkg
installer and follow the on-screen instructions to complete the installation.
2. Configure Environment Variables
To set up JAVA_HOME
and update the PATH
:
- If using bash, open
~/.bash_profile
- If using zsh (default on newer macOS), open
~/.zshrc
Add:
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH=$JAVA_HOME/bin:$PATH
Save the file and reload it:
source ~/.zshrc # or source ~/.bash_profile
✅ Installing Java JDK on Linux
1. Download the Package
Choose the installer based on your Linux distribution:
- Debian/Ubuntu:
.deb
package - RedHat/CentOS/Fedora:
.rpm
package - Generic:
.tar.gz
tarball
2. Install via Terminal
For Debian/Ubuntu:
sudo dpkg -i jdk-xx_linux-x64_bin.deb
For tar.gz (generic installation):
tar -xvzf jdk-xx_linux-x64_bin.tar.gz
sudo mv jdk-xx /opt/
3. Configure Environment Variables
Add the following lines to ~/.bashrc
or ~/.zshrc
:
export JAVA_HOME=/opt/jdk-xx
export PATH=$JAVA_HOME/bin:$PATH
Reload the file:
source ~/.bashrc # or source ~/.zshrc
4. Verify Installation
Run the following commands to confirm Java is installed correctly:
java --version
javac --version
✅ Installing Java JRE
On Windows
Download the Java Runtime Environment (JRE) installer from the official Oracle Java Downloads page. Run the installer, follow the setup prompts, and configure the JRE path in System Environment Variables, similar to the JDK setup process.
On macOS/Linux
In most modern setups, the JRE is already bundled with the JDK. If you still need a standalone JRE, the process is similar: download the installer for your OS, complete the installation, set the JAVA_HOME
environment variable, and verify the installation.
📌 Important Notes
- Most modern JDK packages include JRE by default, so a separate JRE installation is usually unnecessary.
- Always download Java from official sources (Oracle or OpenJDK) to ensure security and long-term support.
- Correct installation and environment variable setup ensure Java is ready for both development (JDK) and runtime (JRE) tasks on your system.