/
mc-node.net →
VPS

How do I install Java on my VPS?

Updated 04/09/20263 min read
In this article
  1. Step 1: connect to your VPS
  2. Step 2: update the package list
  3. Step 3: install Java
  4. Step 4: check
  5. Several versions side by side
  6. Setting the memory
  7. Running a server as a service
  8. Common questions

To run a Minecraft server or another Java application on a VPS, you first need a Java runtime. On Ubuntu and Debian you install it with apt in a few commands. Mind the version: Minecraft 26.x requires Java 25, 1.20.5 to 1.21 Java 21, 1.18 to 1.20.4 Java 17 and old modpacks Java 8. Which version belongs to which Minecraft version is in our blog article which Java version your server needs.

Step 1: connect to your VPS

Connect through SSH as root with the IP address and password from your delivery e-mail; how that works with PuTTY or the terminal is in connecting to your VPS through SSH. If you do not work as root, put sudo in front of the commands below.

Step 2: update the package list

apt update && apt upgrade -y

This fetches the latest package lists and updates the system. Always do this before installing new software.

Step 3: install Java

Pick the version you need. Ubuntu 24.04 and Debian 13 have the recent versions in their own repositories:

  • Java 25: apt install openjdk-25-jre-headless -y
  • Java 21: apt install openjdk-21-jre-headless -y
  • Java 17: apt install openjdk-17-jre-headless -y

headless means without graphical components; exactly what a server needs. If you also want to compile (to develop plugins), take -jdk-headless instead of -jre-headless. The generic package default-jre installs your distribution's default version, but that is not always the version Minecraft wants; choose explicitly instead.

If a version is not in your distribution's repositories (for example Java 25 on an older Ubuntu), use the packages from Adoptium (Eclipse Temurin): add their repository following the instructions on adoptium.net and install temurin-25-jre. Java 8 is also easiest to get from there.

Step 4: check

java -version

You now see something like openjdk version "25.0.1". If the version is right, Java is ready to use.

Several versions side by side

If you run a 26.x server and an old modpack on one VPS, simply install both versions. Which one the java command uses is chosen with:

update-alternatives --config java

Better still is to use the full path in each server's start script, for example /usr/lib/jvm/java-25-openjdk-amd64/bin/java -Xmx4G -jar paper.jar. Then the system default does not matter, and nothing changes if an apt upgrade moves the default.

Setting the memory

Do not give Java all of the VPS's memory: leave about 1 GB for the operating system. On an 8 GB VPS you therefore start a Minecraft server with -Xms6G -Xmx6G. The widely used "Aikar's flags" for the garbage collector reduce stutter with large worlds and work on Java 21 and 25.

Running a server as a service

Do not start a server loose in your SSH session, because it stops as soon as you disconnect. Use a systemd service or a screen session (screen or tmux). If you want to manage several servers with a panel, install Pterodactyl; see installing Pterodactyl manually.

Common questions

  • "Unable to locate package openjdk-25-jre-headless". Your distribution does not have that version; use Adoptium or upgrade the distribution.
  • The server reports "UnsupportedClassVersionError". The active Java is too old; pick the right version with update-alternatives or the full path.
  • Java uses too much memory. Lower -Xmx; Java takes what you allow.

Stuck? Open a ticket with the output of java -version and lsb_release -a.