Problems updating Java on Ubuntu 20.04 for Minecraft 1.18

Solution 1:

Minecraft: Java Edition version 1.18 won't work on Java 8. It requires Java 17. If Minecraft is the only thing you use Java for, I'd suggest uninstalling what you have now:

sudo apt remove default-jre default-jdk
sudo apt autoremove

Now, install OpenJDK 17:

sudo apt update
sudo apt install openjdk-17-jre

We don't install the JDK because it is for compiling Java programs. You aren't, instead you are running one (Minecraft), so you only need the JRE.

Minecraft Version Java Version
1.16 16
1.17 16
1.18 17