Installing OpenJDK 21
The following topics are covered in this article:
macOS
2. Run the following command in Terminal:
brew install openjdk@21
3. After installation, run the following commands as listed under Caveats:
sudo ln -sfn /opt/homebrew/opt/openjdk@21/libexec/openjdk.jdk \ /Library/Java/JavaVirtualMachines/openjdk-21.jdk echo 'export PATH="/opt/homebrew/opt/openjdk@21/bin:$PATH"' >> ~/.bashrc
4. Restart Terminal.
Windows
1. Open a browser and go to:
2. Install OpenJDK:
choco install openjdk --version=21.0.2
3. To set the JAVA_HOME environment variable, Open System Properties.
4. Select Advanced system settings.
5. Click Environment Variables.
6. Under System variables, click New and add:
Variable name: JAVA_HOME
Variable value: C:\Program Files\OpenJDK\openjdk-21
7. In Environment Variables > System variables > Path to update the system path.
8. Click Edit.
9. Add:
C:\Program Files\OpenJDK\openjdk-21\bin