What is available

  • Java Virtual Machine (JVM)
    • A runtime component.
    • It is an interpreter which runs Java code.
  • Java Runtime Environment (JRE)
    • Installed by developers and end-users.
    • To run Java applications.
    • Includes the JVM.
  • Java Development Kit (JDK)
    • Development toolkit.
    • Installed by developers.
    • Includes the JRE.

Download

  • Download page on the website for the runtime.

Install with Package manager

Install with SDKMan!

  1. Install SDKMAN!
  2. Install Java. e.g.
     $ sdk install java 17.0.1-open
    

Install on Linux with APT

Find available packages:

$ sudo apt search openjdk | less
default-jdk
  Standard Java development kit

default-jre
  Standard Java runtime

openjdk-11-jdk
  OpenJDK development kit (JDK)

[...]

Install one. e.g.

$ sudo apt install default-jre

Install on macOS with Homebrew

OpenJDK

$ brew install openjdk

A message I got:

...

For the system Java wrappers to find this JDK, symlink it with
  sudo ln -sfn /usr/local/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk

openjdk is keg-only, which means it was not symlinked into /usr/local,
because macOS provides similar software and installing this software in
parallel can cause all kinds of trouble.

If you need to have openjdk first in your PATH, run:
  echo 'export PATH="/usr/local/opt/openjdk/bin:$PATH"' >> ~/.zshrc

For compilers to find openjdk you may need to set:
  export CPPFLAGS="-I/usr/local/opt/openjdk/include"

Eclipse IDE for Java developers

$ brew install --cask eclipse-java

REPL

$ brew install javarepl