In order to install Java and start programming, you have only to use the Ubuntu package manager:
sudo apt update
sudo apt install default-jdk
Then you have to set JAVA_HOME variable. To do this, first you have to identify Java path:
sudo update-alternatives --config java
After that , you use part of the path to set the JAVA_HOME variable by editing the /etc/environment file.
/etc/environment
It may for example look like this:
JAVA_HOME = “lib/jvm/java-11-oopenjdk-amd64”
Then, in order to let the new variable available and be used, you can type this:
source /etc/environment
All the details are explained in the
video available here .