-
Download JDK:
- Visit the Oracle JDK Downloads page.
- Choose the desired JDK version and download the Windows installer (
.exe
file). - Accept the license agreement during the download.
-
Install JDK:
- Run the downloaded installer.
- Follow the on-screen instructions to complete the installation.
- Note the installation directory (e.g.,
C:\Program Files\Java\jdk-<version>
).
-
Set Environment Variables:
- Set the
JAVA_HOME
system environment variable to the JDK installation directory. - Add the
bin
directory of the JDK to the systemPATH
variable.
- Set the
-
Verify Installation:
- Open a Command Prompt and run:
java -version javac -version
- Open a Command Prompt and run:
-
Download JDK:
- Visit the Oracle JDK Downloads page.
- Choose the desired JDK version and download the macOS installer (
.dmg
file). - Accept the license agreement during the download.
-
Install JDK:
- Open the downloaded
.dmg
file. - Drag the JDK package to the Applications folder.
- Note the installation directory (e.g.,
/Library/Java/JavaVirtualMachines/jdk-<version>.jdk/Contents/Home
).
- Open the downloaded
-
Set Environment Variables (optional):
- macOS usually sets the required environment variables automatically.
- If necessary, you can add the following to your shell profile (e.g.,
~/.bash_profile
or~/.zshrc
):export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-<version>.jdk/Contents/Home export PATH=$PATH:$JAVA_HOME/bin
-
Verify Installation:
- Open a Terminal and run:
java -version javac -version
- Open a Terminal and run:
-
Install OpenJDK via Package Manager:
- Open a Terminal.
- Run the following commands:
sudo apt update sudo apt install default-jdk
-
Set Environment Variables (optional):
- Open your shell profile (e.g.,
~/.bashrc
or~/.zshrc
). - Add the following lines:
export JAVA_HOME=/usr/lib/jvm/default-java export PATH=$PATH:$JAVA_HOME/bin
- Open your shell profile (e.g.,
-
Verify Installation:
- Run:
java -version javac -version
- Run:
These instructions should help you set up the Java Development Kit (JDK) on Windows, macOS, and Linux. Adjust the paths and commands as needed for specific versions and system configurations.