Installing JDK 8: A Comprehensive Guide for Developers
Java Development Kit (JDK) 8, released in March 2014, remains one of the most widely used versions of Java due to its long-term support (LTS) status, stability, and extensive adoption in enterprise environments. Even with newer versions like JDK 11, 17, and beyond, many legacy applications and frameworks still rely on JDK 8. This guide will walk you through installing JDK 8 on Windows, macOS, and Linux, along with best practices, troubleshooting tips, and environment setup.
Table of Contents#
- Prerequisites
- Downloading JDK 8
- Installation Steps by Operating System
- Verifying the Installation
- Setting Up Environment Variables (JAVA_HOME)
- Best Practices
- Common Issues and Troubleshooting
- Conclusion
- References
Prerequisites#
Before installing JDK 8, ensure your system meets the following requirements:
| Operating System | Minimum Requirements |
|---|---|
| Windows | Windows 7/8/10/11 (32-bit or 64-bit); 128 MB RAM; 1 GB free disk space. |
| macOS | macOS 10.8 (Mountain Lion) or later; 64-bit processor; 1 GB free disk space. |
| Linux | 64-bit Ubuntu 14.04+/Debian 8+/RHEL 6+/CentOS 6+; 128 MB RAM; 1 GB free disk space. |
Note: Administrative privileges are required to install JDK on all operating systems.
Downloading JDK 8#
JDK 8 is available from multiple sources. The two most popular options are:
1. Oracle JDK 8 (Official, Requires Login)#
Oracle provides official JDK 8 builds, but since January 2019, Oracle JDK 8 requires a paid license for commercial use. You can download it for free for development/testing (non-commercial) from the Oracle JDK Archive.
2. Eclipse Temurin (Adoptium, Free & Open-Source)#
For free, open-source, and production-ready JDK 8 builds, use Eclipse Temurin (formerly AdoptOpenJDK). It is fully compatible with Oracle JDK and licensed under the GPLv2 with Classpath Exception.
Recommendation: Use Eclipse Temurin for most users, as it avoids licensing complexities.
Installation Steps by Operating System#
Windows#
Step 1: Download the Installer#
- Go to Eclipse Temurin JDK 8 Downloads.
- Select your OS (Windows), architecture (x64 for 64-bit, x86 for 32-bit), and download the
.msiinstaller (e.g.,OpenJDK8U-jdk_x64_windows_hotspot_8u382b05.msi).
Step 2: Run the Installer#
- Double-click the downloaded
.msifile. - In the setup wizard:
- Welcome Screen: Click "Next".
- Installation Directory: Use the default path (
C:\Program Files\Eclipse Adoptium\jdk-8.0.382.05-hotspot) or choose a custom location. Avoid spaces in the path (e.g.,C:\Java\jdk8). - Features: Ensure "Add to PATH" and "Set JAVA_HOME variable" are checked (optional but recommended).
- Click "Install" and wait for completion.
Step 3: Complete Installation#
- Click "Finish" to exit the wizard.
macOS#
Step 1: Download the Installer#
- Go to Eclipse Temurin JDK 8 Downloads.
- Select "macOS" and "x64" (or "aarch64" for Apple Silicon), then download the
.pkginstaller (e.g.,OpenJDK8U-jdk_x64_mac_hotspot_8u382b05.pkg).
Step 2: Run the Installer#
- Double-click the
.pkgfile. - In the installer:
- Click "Continue" on the welcome screen.
- Accept the license agreement.
- Choose the destination (usually "Macintosh HD").
- Click "Install" and enter your macOS password when prompted.
Step 3: Verify Installation Path#
macOS typically installs JDK 8 to:
/Library/Java/JavaVirtualMachines/temurin-8.jdk/Contents/Home
Linux (Ubuntu/Debian)#
Option 1: Using APT (Recommended for Ubuntu 20.04+)#
Eclipse Temurin provides APT repositories for easy installation:
- Add the Adoptium GPG key:
wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | sudo apt-key add - - Add the repository:
echo "deb https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | sudo tee /etc/apt/sources.list.d/adoptium.list - Update and install JDK 8:
sudo apt update && sudo apt install temurin-8-jdk
Option 2: Manual Installation (For Older Distros)#
- Download the
.tar.gzfile from Eclipse Temurin (e.g.,OpenJDK8U-jdk_x64_linux_hotspot_8u382b05.tar.gz). - Extract the archive to
/usr/lib/jvm/:sudo tar -xzf OpenJDK8U-jdk_x64_linux_hotspot_8u382b05.tar.gz -C /usr/lib/jvm/ - Rename the folder for clarity (optional):
sudo mv /usr/lib/jvm/jdk8u382-b05 /usr/lib/jvm/temurin-8-jdk
Linux (RHEL/CentOS)#
Option 1: Using YUM/DNF#
- Add the Adoptium YUM repository:
sudo curl -L https://packages.adoptium.net/artifactory/api/gpg/key/public | sudo tee /etc/pki/rpm-gpg/RPM-GPG-KEY-Adoptium - Create a repo file:
sudo tee /etc/yum.repos.d/adoptium.repo <<EOF [Adoptium] name=Adoptium baseurl=https://packages.adoptium.net/artifactory/rpm/centos/8/\$basearch enabled=1 gpgcheck=1 gpgkey=/etc/pki/rpm-gpg/RPM-GPG-KEY-Adoptium EOF - Install JDK 8:
sudo dnf install temurin-8-jdk # For RHEL 8+/CentOS 8+ # OR sudo yum install temurin-8-jdk # For RHEL 7/CentOS 7
Option 2: Manual Installation#
Same as Ubuntu/Debian, but extract to /usr/lib/jvm/.
Verifying the Installation#
After installation, verify JDK 8 is correctly installed by checking the version:
-
Open a terminal/command prompt.
-
Run:
java -versionExpected Output (Temurin):
openjdk version "1.8.0_382" OpenJDK Runtime Environment (Temurin)(build 1.8.0_382-b05) OpenJDK 64-Bit Server VM (Temurin)(build 25.382-b05, mixed mode) -
Verify the compiler (
javac):javac -versionExpected Output:
javac 1.8.0_382
If you see these outputs, JDK 8 is installed successfully.
Setting Up Environment Variables (JAVA_HOME)#
JAVA_HOME is an environment variable that points to the JDK installation directory. Many tools (e.g., Maven, Gradle, Tomcat) require it.
Windows#
- Open System Properties (Win + Pause/Break or right-click "This PC" → "Properties").
- Click "Advanced system settings" → "Environment Variables".
- Under "System Variables", click "New".
- Variable name:
JAVA_HOME - Variable value: Path to JDK (e.g.,
C:\Program Files\Eclipse Adoptium\jdk-8.0.382.05-hotspot).
- Variable name:
- Update the
PATHvariable:- Select "Path" → "Edit".
- Add
%JAVA_HOME%\bin(or%JAVA_HOME%\bin;if other entries exist).
- Click "OK" to save.
- Restart your terminal for changes to take effect.
macOS/Linux#
- Open your shell profile file (e.g.,
~/.bashrc,~/.zshrc, or~/.profile). - Add the following lines:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/temurin-8.jdk/Contents/Home # macOS # OR (Linux) export JAVA_HOME=/usr/lib/jvm/temurin-8-jdk export PATH=$JAVA_HOME/bin:$PATH - Save the file and reload the profile:
source ~/.bashrc # or ~/.zshrc
Verify JAVA_HOME:
echo $JAVA_HOME
# Output should match your JDK pathBest Practices#
1. Use Open-Source Distributions (e.g., Temurin)#
Avoid Oracle JDK 8 for commercial use unless you have a license. Eclipse Temurin, Amazon Corretto, or Azul Zulu are free, open-source alternatives with long-term support.
2. Keep JDK 8 Updated#
JDK 8 receives security patches (e.g., 8u382 is the latest as of 2023). Update regularly to mitigate vulnerabilities. Use your package manager (APT/YUM) or download the latest installer from Adoptium.
3. Manage Multiple JDK Versions#
If you work with multiple Java versions, use tools like:
- SDKMAN! (Linux/macOS):
sdk install java 8.0.382-tem - jEnv (macOS/Linux):
jenv add /path/to/jdk8 - Chocolatey (Windows):
choco install temurin8
4. Avoid Installing in Non-Standard Paths#
Stick to default installation paths (e.g., C:\Program Files\ on Windows, /usr/lib/jvm/ on Linux) to avoid path-related issues with build tools.
5. Secure Your JDK#
- Restrict file permissions: Ensure only admins can modify the JDK directory.
- Disable unused features (e.g.,
java.rmiif not needed) via JVM flags.
Common Issues and Troubleshooting#
1. "java: command not found"#
- Cause:
PATHvariable not updated. - Fix: Verify
%JAVA_HOME%\bin(Windows) or$JAVA_HOME/bin(macOS/Linux) is inPATH.
2. Multiple JDK Versions Conflicting#
- Cause: Older JDK versions may be优先 in
PATH. - Fix: Reorder
PATHto place JDK 8’sbindirectory first, or useupdate-alternatives(Linux):sudo update-alternatives --config java sudo update-alternatives --config javac
3. Installation Fails on Linux (Permission Denied)#
- Cause: Insufficient privileges.
- Fix: Use
sudofor package managers or manual extraction (e.g.,sudo tar -xzf ...).
4. JAVA_HOME Not Recognized#
- Cause: Typo in
JAVA_HOMEpath or profile file not reloaded. - Fix: Double-check the path and run
source ~/.bashrc(Linux/macOS) or restart the terminal (Windows).
5. Oracle JDK 8 License Prompt#
- Fix: Switch to Eclipse Temurin to avoid licensing prompts.
Conclusion#
Installing JDK 8 is straightforward once you follow the steps for your operating system. By using open-source distributions like Eclipse Temurin, setting up JAVA_HOME, and following best practices, you can ensure a stable environment for Java development. Always keep JDK 8 updated and manage multiple versions with tools like SDKMAN! to streamline your workflow.