en:vps:jak-zainstalowac-java-na-serwerze-vps

How to install Java on a VPS server?

This guide shows how to install Java for Debian 10 and above and on Ubuntu 18.04 and above.


We will first get rid of all versions of Java from the VPS to prevent conflicts and to make sure that the version of Java we want is always used.

We will do this by executing one simple command that will remove the dependencies required regardless of which version of Java and from which distributor we have, and therefore the packages that require it.

sudo apt purge java-common -y

It is also worth getting rid of other leftovers that are no longer needed:

sudo apt autoremove -y

First, we will make sure that there are applications on the system that will make it easy to add the necessary repositories:

sudo apt update
sudo apt install -y software-properties-common gnupg

Next, we will add the repositories that are common to all versions:

wget -O- https://apt.corretto.aws/corretto.key | sudo apt-key add -
sudo add-apt-repository 'deb https://apt.corretto.aws stable main'
sudo apt update

Now install the Java version of your choice:

  • If you want to run Minecraft server version 1.17 or later, choose Java 18:
sudo apt install -y java-18-amazon-corretto-jdk
  • If you want to run Minecraft server version 1.12 to 1.16.5, choose Java 11:
sudo apt install -y java-11-amazon-corretto-jdk
  • If you want to run Minecraft server version 1.11.2 or older, choose Java 8:
sudo apt install -y java-1.8.0-amazon-corretto-jdk

Execute the command:

java -version

If the Java version matches the one you have selected and the feedback shows the word Corretto, this means that the installation was successful.

  • en/vps/jak-zainstalowac-java-na-serwerze-vps.txt
  • ostatnio zmienione: 05/05/2023 19:10
  • przez reconv