SDKMAN! is a tool for managing parallel versions of multiple Software Development Kits on most Unix based systems. It provides a convenient Command Line Interface (CLI) and API for installing, switching, removing and listing Candidates.
Follow the official SDKMAN! install instructions.
curl -s "https://get.sdkman.io" | bash source "$HOME/.sdkman/bin/sdkman-init.sh"
Before starting, a useful command to remember is "list" which shows all available versions:
sdk list java
Now install Java & Gradle:
sdk install java YOUR-VERSION
sdk install gradle YOUR-VERSION
Note, the JDK & Gradle install will be in a hidden folder located at (You may have to press Ctrl + H to view hidden folders in Ubuntu's file explorer):