مشاركة عبر


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.

Alternatively, you can use native installers for your operating system of choice, as described in the next section.

Native installers

For Windows, we produce an EXE installer with a graphical interface. For macOS, we produce a PKG installer with similar features. These installers automatically make the JDK (Java Development Kit) 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 either the EXE installer, or ZIP package. On Windows 10 or later, you can also use the Windows Package Manager from your Windows Terminal.

Note

You should only use one installation method (EXE, MSI, or ZIP) at a time for each JDK version. If you previously installed a given JDK LTS (Long Term Support) version using one method (example: MSI) and want to update it using a different method (example: EXE), you must first uninstall the existing JDK before proceeding with the new installation.

The EXE (Windows executable) provides both a graphical and a console-only installation method. If you double-click on the installer file, it launches the traditional Windows application installer, where you can follow the instructions on the screen.

For wide-scale deployment, you can install the EXE on the command line using the following steps:

  1. Download the .exe file. For more information, see Download the Microsoft Build of OpenJDK.

  2. Choose the features you want to install from the following table:

    Feature Description
    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 from launching from PATH when the Microsoft Build of OpenJDK is uninstalled. Reinstall Oracle Java if you need to restore the Oracle registry keys.

  3. Run the EXE file from the command line. Use the selected features, as shown in the following example.

    .\<package>.exe /SILENT /SUPPRESSMSGBOXES /ALLUSERS /TASKS="FeatureEnvironment,FeatureJarFileRunWith" /DIR="C:\Program Files\Microsoft\"
    

    Note

    If installing for only the current user, use the flag /CURRENTUSER instead of /ALLUSERS.

    To suppress the progress bar screen of the installation, use the flag /VERYSILENT instead of /SILENT.

    The /DIR flag is optional. If omitted, then the default installation dir is used based on the installation mode: /ALLUSERS or /CURRENTUSER.

Install on macOS

Packages for macOS are available through Homebrew or as standalone downloads in PKG (macOS package installer) or TAR.GZ formats.

To install the latest version with Homebrew:

brew install --cask microsoft-openjdk

This command produces output similar to:

==> Downloading https://aka.ms/download-jdk/microsoft-jdk-25.0.1-macos-x64.pkg
Already downloaded: /Users/foobar/Library/Caches/Homebrew/downloads/c3df619c6411aa15151d0306a6a0f9760ff7ab0b54d0b00daade382500369c81--microsoft-jdk-25.0.1-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
# OR
brew install --cask microsoft-openjdk@25

To uninstall the Microsoft Build of OpenJDK installed through Homebrew, use the following commands:

sudo rm -rf /Library/Java/JavaVirtualMachines/microsoft-25.jdk
sudo pkgutil --forget com.microsoft.25.jdk

Install on Linux

The following sections provide instructions for installing the Microsoft Build of OpenJDK on various Linux distributions.

To install on Ubuntu 18.04, 20.04, 22.04, and 24.04 LTS versions, open a terminal and run the following commands:

# Valid values are only '18.04', '20.04', '22.04', and '24.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-25

Note

You might have to update your default JDK selection. See here for details.

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-25-amd64

For CentOS, you can use the alternatives command to manage Java versions.

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.