423

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?

17
  • 1
    Changing the registry was never actually needed. And when not manipulating the system, you don’t need an uninstaller either.
    – Holger
    Sep 26, 2018 at 7:17
  • 1
    @Gili using JAVA_HOME environment variable or through direct path in config like IntelliJ IDEa does it? Sep 26, 2018 at 21:25
  • 19
    There is a community project ojdkbuild which provides Windows installers for OpenJDK. JDK 11 is not available there yet but I hope we will get it soon. Sep 27, 2018 at 3:48
  • 1
    @Gili wiki.eclipse.org/FAQ_How_do_I_run_Eclipse%3F#Find_the_JVM note how registry does not appear anywhere…
    – Holger
    Sep 27, 2018 at 6:06
  • 2
    @Robert well, without a browser plugin, control panel, automatic update tool, nor the ask toolbar crapware, there is not so much left to install.
    – Holger
    Sep 27, 2018 at 6:32

12 Answers 12

583
  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"
  3. 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.
  4. 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.

17
  • 10
    Don't forget the registry entries, which are e.g. used by Launch4j for finding installed jre/jdk.
    – Robert
    Sep 27, 2018 at 11:39
  • 2
    @Lior: This is just one program I know that uses the registry entries. There may be dozens or hundred of other programs using these registry entries, too.
    – Robert
    Sep 28, 2018 at 7:32
  • 5
    It may be so, but: a. I worked with Java since ver 1.1 without setting the registry - so it is not a must. b: the windows registry is commonly considered as a mechanism to avoid (e.g. blog.codinghorror.com/was-the-windows-registry-a-good-idea) - hence I don't think it should be used, if not specifically needed. e.g. - a mistake setting a value in it can lead to a hard-to-recover-from error. Sep 28, 2018 at 15:31
  • 30
    > You can point the JAVA_HOME to the folder where you have multiple JDK installations. This is completely wrong. Many programs and scripts assume JAVA_HOME points to default java installation (jdk or jre) and they search for binaries under "%JAVA_HOME%\bin". So you CANNOT point JAVA_HOME to folder with multiple jdk installations. Instead you can add to Path the value "%JAVA_HOME%\bin;" and then (when new JDK installed) you can update JAVA_HOME only
    – kool79
    Dec 4, 2018 at 11:29
  • 3
    Please add that you have to move your Java11 PATH entry to the beginning of the PATH. This to override some (multiple!) path settings to "...\Oracle\Java\javapath". If you don't do this, the test can fail. Apr 24, 2019 at 13:52
280

Java 17 (LTS) and up

For Java 17 and up, you can use the Eclipse Adoptium website. According to their about section, the Eclipse Adoptium project is the continuation of the original AdoptOpenJDK mission.

Java 11 (LTS), Java 8 - 16

For Java 11 (8 through 16), you can use AdoptOpenJDK, a 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...).

2
  • 35
    Although the accepted answer is correct, this is a much more convenient way to install any version of the JDK/JRE
    – optevo
    Oct 16, 2019 at 4:00
  • @AJDhaliwal I have edited the answer to more prominently display Eclipse Adoptium.
    – Pimgd
    Sep 21, 2022 at 9:00
41

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.

11
  • 4
    Note that this would install latest version: openjdk-12.0.2_windows-x64
    – Vadzim
    Sep 9, 2019 at 7:27
  • 1
    in case you have other java versions installed you might want to check the path variables and remove/modify the old.
    – Ketu
    Oct 17, 2019 at 6:06
  • 2
    @Vadzim choco install openjdk11 as of today without mentioning the version, it installs openjdk-13 and just to note, it will use the AdoptOpenJDK as in other answers
    – F.I.V
    Mar 14, 2020 at 14:27
  • 1
    @GodstimeOsarobo You may need to close & reopen your shell window (cmd/powershell), as only then the PATH environment variable is updated appropriately.
    – Tobias
    Jun 21, 2021 at 6:17
  • 1
    You can use chocolatey and specifically ask for OpenJDKv11: choco install openjdk --version=11.0. As noted here.
    – idrositis
    May 2, 2022 at 14:25
24

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

4
  • 4
    For me those builds didn't set the PATH variables properly. At lease I can't issue java -version and get the desired output.
    – hannes101
    Jan 16, 2019 at 8:45
  • 1
    I can't find OpenJDK msi. I'll do script and share it in an answer later today that extracts and sets PATH and JAVA_HOME for the machine.
    – vezenkov
    Jan 16, 2019 at 13:05
  • 1
    @vezenkov: Update the answer here (it's community wiki for a reason) and/or open an issue with the project, please. Jan 16, 2019 at 13:08
  • To add to the accepted answer if you were upgrading from a previous version I had to even restart the server to see the openjdk version get updated on the command line.
    – desiguy
    Nov 26, 2019 at 17:02
5

JDK builds

Basically, there is only one set of source code for the JDK. It is hosted in Mercurial at OpenJDK. Anyone can take the source code, produce a build, and post it. So, Oracle created a certification process that should be used to ensure the build is valid. This certification is run by the Java Community Process, which provides a Technology Compatibility Kit (TCK or JCK as Java). If an organization produces an OpenJDK build that passes the TCK then that build can be described as “Java SE compatible”.

Eclipse Temurin
AdoptOpenJDK has been moved to the Eclipse Foundation and rebranded to Eclipse Adoptium project. The Adoptium OpenJDK builds are called Eclipse Temurin to distinguish the project from the builds. Eclipse Temurin builds are high-quality, vendor-neutral, and TCK-tested under a permissive license. Temurin is available for a wide range of platforms and Java SE versions.

Zulu
You can check Zulu from Azul. Azul provides open source OpenJDK builds called Azul Zulu for many operating systems and architectures. Azul Platform Core provides 100% open source, fully tested and certified, Java SE standards-compliant, well-curated builds of OpenJDK. Zulu is compliant with Java SE specifications, and has an identical level of performance to the Oracle offering, making it an easy “drop-in” replacement for Oracle HotSpot.

Amazon Corretto
You can also 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.

TCK Compliant
One more thing I like to highlight here is that all the mentions builds are TCK Compliant. You can see the OpenJDK builds comparison here and here.

Check this guide to decide which jdk suits best for your needs.

4

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:

3

Scoop installs programs you know and love, from the command line with a minimal amount of friction.

  • Install scoop
  • Add java scoop bucket add java
  • Install OpenJDK scoop.cmd install openjdk17
2

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

1

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.

1

WinGet is now available on Windows 10+ to install the Microsoft Build of OpenJDK on your machine. See details and access the downloads page at https://aka.ms/msopenjdk/ where you can find more instructions and packages you may find useful.

0

Here is the complete answer. first of all you have to install the Chocolatey. to install Chocolatey run powershell as administrator and run the following command

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

after this run open cmd as administrator and run this command

choco install -y openjdk11

it will install the openjdk to the following location

C:\Program Files\Eclipse Adoptium\jdk-11.0.16.101-hotspot

finllay set your JAVA_HOME TO

C:\Program Files\Eclipse Adoptium\jdk-11.0.16.101-hotspot

and cheers

0

Try this also. choco install -y microsoft-openjdk11

Not the answer you're looking for? Browse other questions tagged or ask your own question.