Install the Microsoft Build of OpenJDK
This article describes how to install the Microsoft Build of OpenJDK. To get the files mentioned in this article, see Download the Microsoft Build of OpenJDK.
ZIP and TAR.GZ packages
For Windows, Linux, and macOS, we produce ZIP (Windows) and TAR.GZ (Linux/macOS) packages. To install, extract one of these packages in a folder of your choice, then set the JAVA_HOME
environment variable to that folder.
Alternately, you can use native installers for your OS of choice, as described in the next section.
Native installers
For Windows, we produce an MSI installer with a graphical interface. For macOS, we produce a PKG installer with similar features. These installers will automatically make the JDK tools available in your PATH
.
For Linux, we produce DEB and RPM packages to be used with apt
and rpm
.
The following sections provide instructions for these installers.
Install on Windows
To install on any version of Windows, you can use the MSI packages or the ZIP package. If you're on Windows 10 or later, you can use the Windows Package Manager from your Windows Terminal.
Install on Windows via MSI
The MSI installer provides both a graphical and a console-only installation method. If you double-click on the MSI file, it will launch the tradition Windows application installer, where you can follow the instructions on the screen.
For widescale deployment, you can install the MSI on the command line using the following steps:
Download the .msi file. For more information, see Download the Microsoft Build of OpenJDK.
Choose the features you want to install from the following table:
Feature Description FeatureMain
Core installation (DEFAULT) FeatureEnvironment
Update the PATH
environment variable. (DEFAULT)FeatureJarFileRunWith
Associate .jar files with Java applications. (DEFAULT) FeatureJavaHome
Update the JAVA_HOME
environment variable.FeatureOracleJavaSoft
Updates registry keys HKLM\SOFTWARE\JavaSoft\
.Note
You can use
FeatureOracleJavaSoft
to prevent Oracle Java launching from PATH when Microsoft Build of OpenJDK is uninstalled. Reinstall Oracle Java if you need to restore the Oracle registry keys.You can use optional parameters that group some of the features together, as shown in the following example:
Parameter Features INSTALLLEVEL=1
FeatureMain,FeatureEnvironment,FeatureJarFileRunWith
Run the
msiexec
command command on the target workstation. Use the selected features, as shown in the following example.msiexec /i <package>.msi ADDLOCAL=FeatureMain,FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome INSTALLDIR="c:\Program Files\Microsoft\" /quiet
Note
You must use
INSTALLDIR
withFeatureMain
.This example silently installs the Microsoft Build of OpenJDK, updates the
PATH
, associates .jar files with Java applications, and definesJAVA_HOME
.
Install on Windows with the Windows Package Manager (winget)
To install with the Windows Package Manager, first install winget, and then open the Windows Terminal.
Next, use the following command to search for the Microsoft Build of OpenJDK packages:
winget search Microsoft.OpenJDK
You'll see output similar to the following:
Name Id Version
--------------------------------------------------------------
Microsoft Build of OpenJDK 21 Microsoft.OpenJDK.21 21.0.0
You can now install the package by referencing the Id
shown above, using the following command:
winget install Microsoft.OpenJDK.21
This command produces an output similar to the following:
Found Microsoft Build of OpenJDK 21 [Microsoft.OpenJDK.21]
This application is licensed to you by its owner.
Microsoft is not responsible for, nor does it grant any licences to, third-party packages.
Downloading https://aka.ms/download-jdk/microsoft-jdk-21.0.0-windows-x64.msi
██████████████████████████████ 160 MB / 160 MB
Successfully verified installer hash
Starting package install...
Successfully installed
Install on macOS
Packages for macOS are available through Homebrew or as standalone downloads in PKG or TAR.GZ formats.
To install the latest version with Homebrew:
brew install --cask microsoft-openjdk
This command produces a output similar to the following:
==> Downloading https://aka.ms/download-jdk/microsoft-jdk-21.0.0-macos-x64.pkg
Already downloaded: /Users/foobar/Library/Caches/Homebrew/downloads/c3df619c6411aa15151d0306a6a0f9760ff7ab0b54d0b00daade382500369c81--microsoft-jdk-21.0.0-macos-x64.pkg
==> Installing Cask microsoft-openjdk
==> Running installer for microsoft-openjdk; your password may be necessary.
Package installers may write to any location; options such as `--appdir` are ignored.
Password:
installer: Package name is Microsoft Build of OpenJDK
installer: Installing at base path /
installer: The install was successful.
🍺 microsoft-openjdk was successfully installed!
Note
The package microsoft-openjdk
points to the latest version of the Microsoft Build of OpenJDK.
To install other major versions with Homebrew:
brew install --cask microsoft-openjdk@11
# OR
brew install --cask microsoft-openjdk@17
# OR
brew install --cask microsoft-openjdk@21
To install on macOS with the TAR.GZ package, just extract the file into a location. The JDK will be inside <location>/jdk-<version>/Contents/Home
.
To install using the PKG installer, open the installer and follow the instructions. By default, the JDK will be installed at /Library/Java/JavaVirtualMachines/microsoft-21.jdk/Contents/Home
.
Uninstall on macOS
To uninstall the Microsoft Build of OpenJDK installed through Homebrew or PKG, use the following commands:
sudo rm -rf /Library/Java/JavaVirtualMachines/microsoft-21.jdk
sudo pkgutil --forget com.microsoft.21.jdk
To uninstall the package installed through the TAR.GZ package, simply delete the folder.
Install on Ubuntu
To install on Ubuntu 18.04, 20.04, and 22.04 LTS versions, open a terminal and run the following commands:
# Valid values are only '18.04', '20.04', and '22.04'
# For other versions of Ubuntu, please use the tar.gz package
ubuntu_release=`lsb_release -rs`
wget https://packages.microsoft.com/config/ubuntu/${ubuntu_release}/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
After the repository is added, install the Microsoft Build of OpenJDK by running the following commands:
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install msopenjdk-21
Note
You may have to update your default JDK selection, see here for details.
Install on Debian
Debian 10 - 12
Warning
As of July 2024, official support for Debian 10 has ended. All published JDKs up to July 2024 remain available, but will not recieve continued updates or support
To install on Debian 10 through 12, open a terminal and run the following commands:
sudo apt update
sudo apt install wget lsb-release -y
wget https://packages.microsoft.com/config/debian/$(lsb_release -rs)/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
After the repository is added, run the following commands:
sudo apt update
sudo apt install msopenjdk-21
Note
You may have to update your default JDK selection, see here for details.
Debian 9
Warning
As of July 2024, official support for Debian 9 has ended. All published JDKs up to July 2024 remain available, but will not recieve continued updates or support
To install on Debian 9, open a terminal and run the following commands:
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -o root -g root -m 644 packages.microsoft.gpg /etc/apt/trusted.gpg.d/
wget -q https://packages.microsoft.com/config/debian/9/prod.list -O /etc/apt/sources.list.d/microsoft-prod.list
After the repository is added, run the following commands:
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install msopenjdk-21
Note
You may have to update your default JDK selection, see here for details.
Install on CentOS 7 (RPM)
To install on CentOS 7, open a terminal and run the following command:
sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
After the repository is added, run the following command:
sudo yum install msopenjdk-21
Note
RPM packages for msopenjdk-21
may not update automatically to the latest minor version. To check for the available/latest versions, run yum -v list msopenjdk-21
. Then, run yum install msopenjdk-21-<version>
to force update to the version specified. Example: yum install msopenjdk-21-21.0.0-1
Install on Alpine (TAR.GZ)
To install on Alpine, simply download a tar.gz
package for Alpine (see the download page) and extract the folder.
Note
Alpine is only supported for JDK 11 and JDK 17. We will no longer be supporting alpine for JDK21 onward.
Change the default JDK on Linux
If you have several versions of OpenJDK installed on your system, use the following command to set the Microsoft Build of OpenJDK as the default:
For Debian/Ubuntu:
sudo update-java-alternatives --set msopenjdk-21-amd64
For CentOS, you can use the command alternative
.
Provide feedback on the Microsoft Build of OpenJDK
Send us your comments, thoughts, and ideas to help us improve the Microsoft Build of OpenJDK. Visit our OpenJDK discussions page on GitHub to send us your feedback.
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.