Java 17, also known as the seventeenth major release of the Java SE platform, represents a significant milestone as it is the latest Long-Term Support (LTS) version. This designation means that Oracle will provide commercial support and security updates for an extended period, making it an attractive choice for developers and organizations looking for stability and longevity in their software projects. Installing Java 17 involves obtaining the correct distribution and configuring your system to recognize and utilize it. This guide will walk you through the process, covering common operating systems and essential post-installation steps.

Understanding Java Distributions
Before diving into the installation process, it’s important to understand the different types of Java distributions available. While Oracle JDK was once the de facto standard, the licensing changes introduced with Java 11 and subsequent versions have led many to seek alternatives.
Oracle JDK vs. OpenJDK
- Oracle JDK: Oracle provides its own build of the JDK. Historically, it was free for development and production. However, since Oracle JDK 11, commercial use for production environments requires a paid license. Oracle JDK 17 is an LTS release and falls under these licensing terms. It often includes additional features and optimizations not present in OpenJDK, though the core functionality is largely the same.
- OpenJDK: OpenJDK is the open-source reference implementation of the Java Platform, Standard Edition. It serves as the foundation for most other JDK distributions. Many vendors, including Adoptium (formerly AdoptOpenJDK), Red Hat, Amazon, Microsoft, and Azul, provide their own builds of OpenJDK. These builds are typically free for commercial use and are highly recommended for most development and production scenarios, especially if you wish to avoid Oracle’s licensing fees.
For the purpose of this guide, we will focus on installing OpenJDK, as it is the most common and recommended approach for developers today. Specifically, we will use the Adoptium Temurin distribution, which is a popular, high-quality, and free open-source build of OpenJDK.
Choosing an OpenJDK Distribution
Several reputable vendors offer OpenJDK builds. Some of the most popular include:
- Adoptium Temurin: A community-driven, Eclipse Foundation project providing high-quality, TCK-certified, GPL-licensed OpenJDK builds. This is our recommended choice for broad compatibility and community support.
- Amazon Corretto: Amazon’s free, multiplatform, production-ready distribution of OpenJDK.
- Microsoft Build of OpenJDK: Microsoft’s free distribution of OpenJDK.
- Azul Zulu Community: Azul’s free, open-source build of OpenJDK.
- Red Hat build of OpenJDK: Red Hat’s actively maintained OpenJDK builds.
For this guide, we will primarily use Adoptium Temurin due to its widespread adoption and excellent community backing. The installation steps for other OpenJDK distributions are very similar.
Installing Java 17 on Different Operating Systems
The installation process for Java 17 varies slightly depending on your operating system. We will cover Windows, macOS, and Linux.
Windows Installation
On Windows, you can install Java 17 by downloading an installer or using a package manager like Chocolatey.
Method 1: Using the Installer (Adoptium Temurin)
-
Download the Installer:
- Navigate to the Adoptium website: https://adoptium.net/
- Select “Temurin 17 (LTS)” from the available versions.
- Choose your operating system (Windows) and the desired architecture (x64 for most modern systems).
- Download the
.msiinstaller.
-
Run the Installer:
- Locate the downloaded
.msifile and double-click it to launch the installation wizard. - Click “Next” on the Welcome screen.
- Accept the license agreement and click “Next.”
- Custom Setup: On this screen, you will see options to customize the installation. It is highly recommended to check the box that says “Set JAVA_HOME variable.” This is crucial for many Java development tools and IDEs to find your Java installation. You can also choose to install development tools (JDK) or just the runtime environment (JRE), though for development, installing the JDK is standard.
- Click “Next.”
- Ready to Install: Click “Install” to begin the installation.
- You may be prompted by User Account Control (UAC) to allow the installer to make changes. Click “Yes.”
- Once the installation is complete, click “Finish.”
- Locate the downloaded
Method 2: Using Chocolatey (Package Manager)
If you have Chocolatey installed, this is a very convenient way to manage Java installations.
-
Open an Administrator PowerShell or Command Prompt:
- Search for “PowerShell” or “Command Prompt” in the Start menu, right-click on it, and select “Run as administrator.”
-
Install Java 17:
- Run the following command:
powershell
choco install temurin17-jdk
- Chocolatey will download and install the latest Temurin 17 JDK, automatically setting the
JAVA_HOMEenvironment variable.
- Run the following command:
Verifying the Installation (Windows)
- Open Command Prompt: Press
Win + R, typecmd, and press Enter. - Check Java Version: Type the following command and press Enter:
bash
java -version
You should see output similar to this, indicating Java 17 is installed:
openjdk version "17.0.x" ...
- Check JAVA_HOME: Type the following command and press Enter:
bash
echo %JAVA_HOME%
This should display the path to your Java 17 installation directory (e.g.,C:Program FilesEclipse Adoptiumjdk-17.0.x.x-hotspot).
macOS Installation
On macOS, you can install Java 17 using a .pkg installer or Homebrew.
Method 1: Using the Installer (Adoptium Temurin)
-
Download the Installer:
- Go to the Adoptium website: https://adoptium.net/
- Select “Temurin 17 (LTS).”
- Choose your operating system (macOS) and architecture (x64 or AArch64 for Apple Silicon).
- Download the
.pkginstaller.
-
Run the Installer:
- Double-click the downloaded
.pkgfile. - Follow the on-screen prompts. Click “Continue,” “Agree” to the license, and then “Install.”
- You will be asked for your administrator password to authorize the installation.
- Once completed, click “Close.”
- Double-click the downloaded
Method 2: Using Homebrew (Package Manager)
Homebrew is a popular package manager for macOS.

-
Open Terminal: You can find Terminal in
Applications/Utilitiesor search for it using Spotlight (Cmd + Space). -
Install Java 17:
- First, ensure Homebrew is up-to-date:
bash
brew update
- Then, install Temurin 17 JDK:
bash
brew install temurin@17
- Homebrew will handle the download and installation, and usually sets up the necessary symbolic links for you.
- First, ensure Homebrew is up-to-date:
Verifying the Installation (macOS)
- Open Terminal.
- Check Java Version: Type the following command and press Enter:
bash
java -version
You should see output indicating Java 17. - Check JAVA_HOME: Homebrew typically manages
JAVA_HOMEautomatically by linking to the installed JDK. To confirm, you can run:
bash
/usr/libexec/java_home -v 17
This command should output the path to your Java 17 installation. If you need to explicitly setJAVA_HOMEin your shell profile (e.g.,.zshrcor.bash_profile), you can use the output from/usr/libexec/java_home. For example, in.zshrc:
bash
export JAVA_HOME=$(/usr/libexec/java_home -v 17)
export PATH=$JAVA_HOME/bin:$PATH
After adding these lines, reload your shell configuration:source ~/.zshrc.
Linux Installation
Linux installations typically involve package managers specific to the distribution or manual extraction.
Method 1: Using Package Managers (Debian/Ubuntu)
- Update Package Lists:
bash
sudo apt update
- Install OpenJDK 17:
- Many Ubuntu and Debian repositories now include OpenJDK 17. Install it using:
bash
sudo apt install openjdk-17-jdk
- If this package isn’t found, you might need to add a PPA or use a different installation method.
- Many Ubuntu and Debian repositories now include OpenJDK 17. Install it using:
Method 2: Using Package Managers (Fedora/CentOS/RHEL)
- Update Package Lists:
- For Fedora:
bash
sudo dnf update
- For CentOS/RHEL (using
yumordnf):
bash
sudo yum update
# or
sudo dnf update
- For Fedora:
- Install OpenJDK 17:
- For Fedora (using
dnf):
bash
sudo dnf install java-17-openjdk-devel
- For CentOS/RHEL (using
yum):
bash
sudo yum install java-17-openjdk-devel
- For Fedora (using
Method 3: Manual Installation (Adoptium Temurin – Tarball)
This method offers more control and works across most Linux distributions.
-
Download the Tarball:
- Go to the Adoptium website: https://adoptium.net/
- Select “Temurin 17 (LTS).”
- Choose your operating system (Linux) and architecture (x64 or AArch64).
- Download the
.tar.gzarchive.
-
Extract the Archive:
- Create a directory to store your Java installations. A common location is
/usr/local/java.
bash
sudo mkdir -p /usr/local/java
- Navigate to the directory where you downloaded the tarball (e.g.,
~/Downloads). - Extract the archive to the
/usr/local/javadirectory:
bash
sudo tar -xzf OpenJDK17U-jdk_x64_linux_hotspot_x.x.x_x.tar.gz -C /usr/local/java/
(ReplaceOpenJDK17U-jdk_x64_linux_hotspot_x.x.x_x.tar.gzwith the actual filename you downloaded.)
- Create a directory to store your Java installations. A common location is
-
Configure Environment Variables:
- You need to set the
JAVA_HOMEenvironment variable and add Java’sbindirectory to yourPATH. This is typically done in your shell’s configuration file (e.g.,~/.bashrcfor Bash or~/.zshrcfor Zsh). - Edit your shell configuration file (e.g.,
nano ~/.bashrc). - Add the following lines, adjusting the path to match your extracted directory:
bash
export JAVA_HOME=/usr/local/java/jdk-17.x.x+x # Example path
export PATH=$JAVA_HOME/bin:$PATH
You can find the exact directory name within/usr/local/javaafter extraction. For example, it might bejdk-17.0.7+8. - Save the file and exit the editor.
- Reload your shell configuration:
bash
source ~/.bashrc
# or
source ~/.zshrc
- You need to set the
Verifying the Installation (Linux)
- Open Terminal.
- Check Java Version: Type the following command and press Enter:
bash
java -version
You should see output indicating Java 17. - Check JAVA_HOME: Type the following command and press Enter:
bash
echo $JAVA_HOME
This should display the path you set in your environment variables.
Configuring JAVA_HOME and PATH
The JAVA_HOME environment variable is a convention used by many Java-based tools and applications to locate the Java installation directory. The PATH environment variable tells the operating system where to find executable programs, including the java, javac, and jar commands.
- Importance of
JAVA_HOME: Many build tools (Maven, Gradle), application servers (Tomcat, WildFly), and IDEs rely onJAVA_HOMEbeing correctly set. Without it, these tools might not function properly or may default to an older Java version. - Importance of
PATH: Adding Java’sbindirectory to yourPATHallows you to run Java commands from any directory in your terminal without specifying the full path to the executable.
Most installers (especially on Windows and macOS with Homebrew) attempt to set these variables for you. However, it’s always good practice to verify and, if necessary, manually configure them as described in the OS-specific sections above. Ensure that the JAVA_HOME variable points to the root directory of your Java Development Kit (JDK) installation, not the bin subdirectory.
Managing Multiple Java Versions (Optional)
In development environments, it’s common to work with projects that require different Java versions. Managing multiple Java installations can be simplified using tools like sdkman! (for Linux/macOS) or by carefully managing your JAVA_HOME and PATH variables.
- sdkman! (Software Development Kit Manager): This is a popular command-line tool for managing parallel versions of multiple SDKs, including Java.
- Install sdkman!:
bash
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
- List Available Java Versions:
bash
sdk list java
- Install Java 17: Find the identifier for a Java 17 distribution (e.g.,
17.0.x-tem) and install it:
bash
sdk install java 17.0.x-tem
- Set Default Version:
bash
sdk default java 17.0.x-tem
sdkman! automatically handles settingJAVA_HOMEandPATHfor the selected version.
- Install sdkman!:

Post-Installation Steps and Best Practices
After successfully installing Java 17, consider these additional steps:
-
IDE Configuration: If you use an Integrated Development Environment (IDE) like IntelliJ IDEA, Eclipse, or VS Code, you will need to configure it to use your new Java 17 installation. Typically, this is done through the IDE’s project settings or global JDK configuration. Ensure your IDE is pointing to the correct
JAVA_HOMEor JDK installation path. -
Set
JAVA_HOMEfor Build Tools:- Maven: Maven typically uses the
JAVA_HOMEenvironment variable. If you have multiple JDKs, you can configure Maven to use a specific one by settingJAVA_HOMEbefore running Maven commands or by configuring thetoolchains.xmlfile. - Gradle: Similar to Maven, Gradle respects
JAVA_HOMEbut also allows explicit configuration withingradle.propertiesor thebuild.gradlefile.
- Maven: Maven typically uses the
-
Environment Variables for Specific Projects: For advanced scenarios or when working with legacy systems, you might need to set
JAVA_HOMEandPATHvariables specific to a project. This is often done using shell scripts or configuration files within the project directory. -
Security Updates: As Java 17 is an LTS release, it will receive security updates and bug fixes. Regularly check for and install updated versions of your chosen OpenJDK distribution to ensure your applications are secure. For users of package managers, updates are often handled through the standard system update process (
apt upgrade,dnf upgrade,brew upgrade).
By following these installation and configuration steps, you will be well-equipped to start developing and deploying applications using Java 17, leveraging its performance improvements, new features, and long-term support.
