A few years back, when we want to download a JDK installer, we go to the Oracle Technology Network website, and download the JDK from it.
Nowadays, you can still download the latest bleeding-edge JDK version (currently is 13.0.2) in the Oracle website after accepting their license terms. If you need to download older JDK versions such as 8 or 11, you need an Oracle account.
Why do we need older Java versions such as 8 and 11? Java 8 and 11 are long-term-support (LTS) versions. These versions are supported and maintained for more than 5 years, and non-LTS versions are only supported for 6 months and their download links are removed from the site after their support has ended. Since LTS are more stable, big projects are made with it. New developers joining their development team needs to download a compatible JDK for themselves. Examples of big projects that uses older JDK are Android Studio and Kotlin Language. According to a study: 64% of developers report that Java 8 remains the most often used release.
OpenJDK as an alternative
OpenJDK is advertised by Oracle itself and other seasoned Java developers. In fact 36% of developers switched from Oracle JDK to an alternate OpenJDK distribution, over the last year 2019.
Option 1: AdoptOpenJDK Website
AdoptOpenJDK is a community of Java users that distributes a pre-compiled JDK distribution for public download.
To install a JDK, go to their website https://adoptopenjdk.net/ and choose the version you want to download. The website automatically detects your OS and CPU architecture – so no need to bother about that.
If you need to download other releases, just go to their releases page (https://adoptopenjdk.net/releases.html) and choose the correct release that you need.
After downloading, just execute the installer file – which is usually double-clicked in most OS.
Option 2: SDKman tool
SDKman is a command-line tool that manages your JDK installation and other JVM related tools such as Gradle, Maven, Grails, Spring Boot, Kotlin, etc...
To install SDKman, just download the bash script from their site. (docs)
When the download completes, run this
source command or start a new terminal session.
When the installation is complete, you can now use the
sdk commands to install JDK.
First, you must determine the JDK version you need to install:
From the list of available versions, install the version you need by running the
sdk install java <Identifier> command.
When the command finishes, the chosen JDK version is now installed and configured. You can now use
javac command in the terminal to build Java programs.
In case you need to install multiple versions of Java, just run the
sdk install java ... command again. After the installation, you need to set the installed Java version to be used in the current shell session temporarily or permanently.
In Linux or MacOS, prefer to install using SDKman. The CLI tool SDKman provides simplifies the download, install, and configuration process of a JDK. In Windows, SDKman is not natively supported. If you want to insist on using SDKman on Windows, you might need to do it in WSL, or Cygwin, or Git Bash.
When using Windows, download an
*.msi installer file from https://adoptopenjdk.net/, then run it just like any executable file in Windows.