To install java on your server, you first need to follow the follwing steps
Fistly, you need to update your package with the command:
sudo apt update -y. When done you will see something appearing as below;
Secondly, you need to upgrade your package with the following command:
sudo apt upgrade -y. When done you need to see something shown as below;
Finally all you need to do is to install java onto your server with the following command:
sudo apt install openjdk-17-jre -y. When done you will see the following image;
NB: To verify if java is installed correctly use this command:
java --version. Then you will see this image below;