How do I downgrade JDK?

You have two options ahead of you:

  1. You can uninstall JDK-16.0.2, then install OpenJDK 11 and have just that implementation on your system
  2. You can install OpenJDK 11 and use update-alternatives to specify which version you want to be treated as default

This answer will focus on the second option, though you can modify it to work for the first.

  1. Open a Terminal (if one is not already open) or SSH into the server you're installing Java onto
  2. Install the default Java runtime. For Ubuntu 20.04, this is version 11.0.11:
    sudo apt install default-jre
    
    If you want to be absolutely certain of the version, you can also specify the version:
    sudo apt install openjdk-11-jre-headless
    
  3. Install the default Java Development Kit:
    sudo apt install default-jdk
    
  4. Confirm the versions:
    java -version
    
    This should give you something like:
    openjdk version "11.0.11"
    OpenJDK Runtime Environment (build 11.0.11+9-post-Ubuntu-3ubuntu1)
    OpenJDK 64-Bit Server VM (build 11.0.11+9-post-Ubuntu-3ubuntu1, mixed mode, sharing)
    
    Also check the compiler:
    javac -version
    
    Which will give you something like:
    javac 11.0.11
    
  5. Set version 11 as the default for the system:
    sudo update-alternatives --config java
    
    This will give you an output similar to:
    There are 2 choices for the alternative java (providing /usr/bin/java).
    
      Selection    Path                                         Priority   Status
      --------------------------------------------------------------------------------
      0            /usr/lib/jvm/java-16-openjdk-amd64/bin/java   1111      auto mode
      1            /usr/lib/jvm/java-16-openjdk-amd64/bin/java   1111      manual mode
    * 2            /usr/lib/jvm/java-11-openjdk-amd64/bin/java   1091      manual mode
    
    Press <enter> to keep the current choice[*], or type selection number:
    
    You can also do this for the compiler with:
    sudo update-alternatives --config javac
    
  6. Confirm your JAVA_HOME variable is correct:
    sudo vi /etc/environment
    
    Note: Feel free to use any text editor that you prefer. The use of vi here is more a force of habit than an endorsement. Locate the JAVA_HOME variable and ensure it's set correctly:
    JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64"
    
    Reload your sources:
    source /etc/environment
    
    Verify the variable is set:
    echo $JAVA_HOME
    
    You should see:
    /usr/lib/jvm/java-11-openjdk-amd64
    

That's all there is to it 👍🏻