How to Install Java (JDK 17)
Recommended version: JDK 17 (Latest LTS)
Setup on macOS
Step 1: Install JDK
Option 1: Using Homebrew (Recommended)
Copy to clipboard
1
brew install openjdk@17Option 2: Manual Installation
Download JDK 17 from:
- Oracle: https://www.oracle.com/java/technologies/downloads/
- Adoptium (OpenJDK): https://adoptium.net/
Step 2: Set JAVA_HOME (Optional but Recommended)
- Open your shell configuration file:
- zsh (default on macOS): ~/.zshrc
- bash: ~/.bash_profile
- Add the following lines:
Copy to clipboard
1
2
export JAVA_HOME=$(/usr/libexec/java_home -v 17)
export PATH=$JAVA_HOME/bin:$PATHSave the file and reload the shell:
Copy to clipboard
1
source ~/.zshrc(or source ~/.bash_profile if using bash)
Step 3: Verify Installation
Run:
Copy to clipboard
1
2
java -version
javac -version
Both commands should return version 17.x without errors.
Setup on Windows
Step 1: Install JDK
- Download JDK 17 (or latest LTS) from:
- Oracle: https://www.oracle.com/java/technologies/downloads/
- Adoptium (OpenJDK): https://adoptium.net/
- Install using default settings.
Default install path:
C:\Program Files\Java\jdk-17\
Step 2: Set Environment Variables
- Open:
Control Panel → System → Advanced system settings → Environment Variables - Under System variables, click New:
- Variable name: JAVA_HOME
- Variable value:
Copy to clipboard
1
C:\Program Files\Java\jdk-17Select the Path variable → Edit → New, then add:
Copy to clipboard
1
%JAVA_HOME%\bin
Click OK to save all changes.
Step 3: Verify Setup
Open Command Prompt
Run:
Copy to clipboard
1
2
java -version
javac -versionBoth commands should respond without errors and show Java 17.
