1. Download OpenJDK 17. To install OpenJDK 17, visit OpenJDK 17 release page and get the latest version available for your CPU architecture,
    1
    wget https://download.java.net/java/GA/jdk17.0.2/dfd4a8d0985749f896bed50d7138ee7f/8/GPL/openjdk-17.0.2_linux-x64_bin.tar.gz
  2. Extract downloaded archive.
    1
    tar xvf openjdk-17.0.2_linux-x64_bin.tar.gz
  3. Move the folder created after extraction.
    1
    sudo mv jdk-17.0.2/ /usr/local/
  4. Set environment variables inside /etc/profile.d/ directory.
    1
    2
    3
    $ sudo vi /etc/profile.d/jdk17.sh
    export JAVA_HOME=/usr/local/jdk-17.0.2
    export PATH=$PATH:$JAVA_HOME/bin
  5. Source the files to make variables available in your current shell session.
    1
    source /etc/profile.d/jdk17.sh
  6. Confirm Java version using the following command.
    1
    2
    3
    4
    $ java --version
    openjdk 17.0.2 2022-01-18
    OpenJDK Runtime Environment (build 17.0.2+8-86)
    OpenJDK 64-Bit Server VM (build 17.0.2+8-86, mixed mode, sharing)