Install Java and Maven on Ubuntu
Mar 11, 2024
Before everything, run the classic update upgrade
sudo apt update
sudo apt upgrade
Search and Install with APT
Now search and install recent Java
apt list -a | grep openjdk
// Found and use the most recent version
sudo apt install openjdk-17-jdk
Then maven
apt list -a | grep maven
// Found Maven
sudo apt install maven
Bonus: How to purge older java
Search for the package
sudo apt list --installed | grep jdk
Purge that package by the name before slash /
For example, mine are JRE 11
sudo apt purge openjdk-11-jre openjdk-11-jre-headless