After looking for the latest version of java to install on my linux system (Java 17 when i'm writting this), i found a really interesting tool to install any version of java available for linux with no harassment, that is SDKMan installer.
First download and install SKDMan with the commands on terminal:
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
You can check your installation with:
sdk version
You can see more options in SDKMan site, but in this tutorial we'll install java openjdk. Run the next command to see the availlable versions.
sdk list java
You should see something like:
Use sdk install java x.y.z-open with your choosen version. In my case:
sdk install java 17.ea.17-open
That's it, your PATH directory is already set and you can use your java command already.