W3docs

How to install JDK 11 under Ubuntu?

To install JDK 11 under Ubuntu, follow these steps:

To install JDK 11 under Ubuntu, follow these steps:

  1. Install OpenJDK 11, the free and default Ubuntu alternative, by running: sudo apt update && sudo apt install -y openjdk-11-jdk
  2. Open a terminal and verify the installation directory by running: update-alternatives --list java
  3. Verify that the full JDK is installed by running: java -version and javac -version This should print the version of the JDK that you just installed.
  4. If multiple Java versions are installed, configure the default by running: sudo update-alternatives --config java
  5. Configure the JAVA_HOME environment variable by adding export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 to your ~/.bashrc or ~/.profile, then run source ~/.bashrc (or restart your terminal / run exec bash to apply changes immediately).