How to install OpenJDK 11 on Windows?

WindowsJava 11

Windows Problem Overview


In the past, Oracle used to publish an executable installers for Windows that would:

  • Unpack files
  • Add registry keys indicating the installed version and path
  • Add the JRE to the system PATH
  • Register an uninstaller with Windows.

As of Java 11, the Oracle's free version of Java (Oracle OpenJDK) doesn't seem to include an installer. It is just a zip file containing the binaries.

How are we supposed to install OpenJDK 11 on Windows seeing as the aforementioned integrations are no longer there? Aren't they necessary?

Windows Solutions


Solution 1 - Windows

  1. Extract the zip file into a folder, e.g. C:\Program Files\Java\ and it will create a jdk-11 folder (where the bin folder is a direct sub-folder). You may need Administrator privileges to extract the zip file to this location.

  2. Set a PATH:

  • Select Control Panel and then System.
  • Click Advanced and then Environment Variables.
  • Add the location of the bin folder of the JDK installation to the PATH variable in System Variables.
  • The following is a typical value for the PATH variable: C:\WINDOWS\system32;C:\WINDOWS;"C:\Program Files\Java\jdk-11\bin"
  1. Set JAVA_HOME:
  • Under System Variables, click New.
  • Enter the variable name as JAVA_HOME.
  • Enter the variable value as the installation path of the JDK (without the bin sub-folder).
  • Click OK.
  • Click Apply Changes.
  1. Configure the JDK in your IDE (e.g. IntelliJ or Eclipse).

You are set.

To see if it worked, open up the Command Prompt and type java -version and see if it prints your newly installed JDK.

If you want to uninstall - just undo the above steps.

Note: You can also point JAVA_HOME to the folder of your JDK installations and then set the PATH variable to %JAVA_HOME%\bin. So when you want to change the JDK you change only the JAVA_HOME variable and leave PATH as it is.

Solution 2 - Windows

AdoptOpenJDK is a new website hosted by the java community. You can find .msi installers for OpenJDK 8 through 16 there, which will perform all the things listed in the question (Unpacking, registry keys, PATH variable updating (and JAVA_HOME), uninstaller...).

As of writing, AdoptOpenJDK still hosts the latest versions of OpenJDK, but in the future, it is planned for new releases to be available at Eclipse Adoptium.

Solution 3 - Windows

Use the Chocolatey packet manager. It's a command-line tool similar to npm. Once you have installed it, use

choco install openjdk --version=11.0

in an elevated command prompt to install OpenJDK 11 (leave out the --version parameter to install the latest version).

To update an installed version to the latest version, type

choco upgrade openjdk

Pretty simple to use and especially helpful to upgrade to the latest version. No manual fiddling with path environment variables.

Solution 4 - Windows

From the comment by @ZhekaKozlov: ojdkbuild has OpenJDK builds (currently 8 and 11) for Windows (zip and msi).

Solution 5 - Windows

You can use Amazon Corretto. It is free to use multiplatform, production-ready distribution of the OpenJDK. It comes with long-term support that will include performance enhancements and security fixes. Check the installation instructions here.

You can also check Zulu from Azul.

One more thing I like to highlight here is both Amazon Corretto and Zulu are TCK Compliant. You can see the OpenJDK builds comparison here and here.

Solution 6 - Windows

For Java 12 onwards, official General-Availability (GA) and Early-Access (EA) Windows 64-bit builds of the OpenJDK (GPL2 + Classpath Exception) from Oracle are available as tar.gz/zip from the JDK website.

If you prefer an installer, there are several distributions. There is a public Google Doc and Blog post by the Java Champions community which lists the best-supported OpenJDK distributions. Currently, these are:

Solution 7 - Windows

https://www.openlogic.com/openjdk-downloads allowed me to pick a 32-bit version of OpenJDK8 (don't ask - Arduino IDE doesn't compile with 11), I think they just wrap around AdoptOpenJDK MSIs but I couldn't find 32-bit distros on AdoptOpenJDK.

Solution 8 - Windows

In addition to the above answers, it is worth noting that you have to move your JDK Path entry to the top of the Path

Inside System Variables Edit Path and Move Up the latest JDK entry to the top

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionGiliView Question on Stackoverflow
Solution 1 - WindowsLior Bar-OnView Answer on Stackoverflow
Solution 2 - WindowsPimgdView Answer on Stackoverflow
Solution 3 - WindowsTobiasView Answer on Stackoverflow
Solution 4 - WindowsMartin SchröderView Answer on Stackoverflow
Solution 5 - WindowsSwapnilView Answer on Stackoverflow
Solution 6 - WindowsBernhard StadlerView Answer on Stackoverflow
Solution 7 - WindowsDavid AirapetyanView Answer on Stackoverflow
Solution 8 - WindowsPrinceView Answer on Stackoverflow