Java Development Kit (JDK) Installation
How to Install the Java Development Kit (JDK)
The Java Development Kit (JDK) is essential for Java programming, as it provides tools for developing and running Java applications. Here’s a step-by-step guide to installing the JDK.
Step 1: Determine Your System Configuration
- Check if your system is 32-bit or 64-bit.
- Windows: Right-click on
This PC
orMy Computer
, selectProperties
, and look for the system type. - Linux: Run
uname -m
in the terminal. - macOS: All recent macOS systems are 64-bit.
- Windows: Right-click on
Step 2: Download the JDK
- Go to the Oracle JDK website:
- Visit the Oracle Java Downloads page.
- Choose your JDK version:
- Select the latest LTS (Long Term Support) version or the version required for your project.
- Download the installer:
- Choose the appropriate installer for your operating system (Windows, macOS, or Linux).
Step 3: Install the JDK
Windows Installation:
- Run the downloaded
.exe
file. - Follow the installation wizard:
- Accept the license agreement.
- Select an installation folder (default is usually fine).
- Complete the installation and note the JDK installation path (e.g.,
C:\Program Files\Java\jdk-XX
).
macOS Installation:
- Run the downloaded
.dmg
file. - Drag the JDK package to the
Applications
folder or follow the on-screen instructions. - Verify installation by opening a terminal and running:
java -version
Linux Installation:
- For Debian-based distributions (Ubuntu):
- Open a terminal and update the package list:
sudo apt update
- Install the JDK (replace
openjdk-X
with your desired version, e.g.,openjdk-17
):sudo apt install openjdk-X-jdk
- Open a terminal and update the package list:
- For RPM-based distributions (Fedora/Red Hat):
- Use
yum
ordnf
to install the JDK:sudo dnf install java-X-openjdk
- Use
Step 4: Configure Environment Variables
- Windows:
- Go to
Control Panel > System > Advanced System Settings > Environment Variables
. - Under “System Variables,” click
New
and add:- Variable Name:
JAVA_HOME
- Variable Value: JDK installation path (e.g.,
C:\Program Files\Java\jdk-XX
).
- Variable Name:
- Add
%JAVA_HOME%\bin
to thePath
variable.
- Go to
- Linux/macOS:
- Open
.bashrc
or.zshrc
in your home directory:nano ~/.bashrc
- Add the following lines:
export JAVA_HOME=/path/to/jdk export PATH=$JAVA_HOME/bin:$PATH
- Save and reload the configuration:
source ~/.bashrc
- Open
Step 5: Verify the Installation
- Open a terminal or command prompt.
- Run:
java -version
- The output should display the installed Java version.
Optional: Install an IDE
- Install an Integrated Development Environment (IDE) like IntelliJ IDEA, Eclipse, or Visual Studio Code to simplify Java development.
You’re all set! You can now start developing Java applications with the JDK.