JDK Download Guide
Choosing the Right JDK
JDK Distribution Options
graph TD
A[JDK Distributions] --> B[OpenJDK]
A --> C[Oracle JDK]
A --> D[Amazon Corretto]
A --> E[Adoptium OpenJDK]
Comparison of JDK Distributions
Distribution |
License |
Cost |
Update Frequency |
OpenJDK |
Open Source |
Free |
Regular |
Oracle JDK |
Commercial |
Paid |
Regular |
Amazon Corretto |
Open Source |
Free |
Regular |
Adoptium OpenJDK |
Open Source |
Free |
Regular |
Downloading OpenJDK on Ubuntu 22.04
Prerequisites
Before downloading, update your system:
sudo apt update
sudo apt upgrade
Installation Methods
Method 1: Using APT Package Manager
## Install default OpenJDK
sudo apt install default-jdk
## Install specific version
sudo apt install openjdk-17-jdk
Method 2: Manual Download
## Download OpenJDK
wget https://download.java.net/java/GA/jdk17/0d483333a00540d886896bac774ff48b/35/GPL/openjdk-17_linux-x64_bin.tar.gz
## Extract the archive
tar -xvf openjdk-17_linux-x64_bin.tar.gz
## Move to /usr/local
sudo mv jdk-17 /usr/local/
Setting Up Environment Variables
## Open bashrc
nano ~/.bashrc
## Add these lines
export JAVA_HOME=/usr/local/jdk-17
export PATH=$PATH:$JAVA_HOME/bin
## Reload configuration
source ~/.bashrc
Verifying JDK Installation
## Check Java version
java --version
## Verify javac compiler
javac --version
LabEx Learning Tip
LabEx provides interactive environments to practice JDK installation and configuration, making the learning process more engaging and hands-on.
Common Troubleshooting
- Ensure sufficient system permissions
- Check download integrity
- Verify system compatibility
- Use official sources for downloads