How to Install Java in Ubuntu
Download and Install Java
First, access your VPS via SSH and determine if you have Java installed.
java -version
You might get the following output:

This means Java is not yet installed. If that’s the case, follow the steps below. Otherwise, proceed to the next step.
- Refresh the APT command to synchronize all repositories:
sudo apt-get update
- Install the newest Java JDK version:
sudo apt install default-jdk -y
- Validate the installation with the same
java -versioncommand we’ve used before. Now, the output should look like this:


