I had installed maven in my ubuntu using command
apt install maven
This installed maven in path /usr/share/maven
Months later, I encountered a maven exception when compiling a java project. The error was as follow:
[ERROR] Error executing Maven.
[ERROR] java.lang.IllegalStateException: Unable to load cache item
[ERROR] Caused by: Unable to load cache item
[ERROR] Caused by: Could not initialize class com.google.inject.internal.cglib.core.$MethodWrapperMy java version at the time was
openjdk version "17.0.2" 2022-10-18
OpenJDK Runtime Environment (build 17.0.2+8-Ubuntu-2ubuntu120.04)
OpenJDK 64-Bit Server VM (build 17.0.2+8-Ubuntu-2ubuntu120.04, mixed mode, sharing)and my maven version at the time was
Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 17.0.2, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-17-openjdk-amd64
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "5.10.16.3-microsoft-standard-wsl2", arch: "amd64", family: "unix"The cause of the error was that maven version(3.6.3) is old. I needed to upgrade to the latest version of maven.
Unfortunately, I could not upgrade to the latest maven version (3.9.0 at the time) using the aptpackage manager on Ubuntu. Generally, the easiest way to install anything on Ubuntu is via the apt package manager. However, it often does not include the latest JDK packages.
These are the steps to install the latest maven version on Ubuntu:
- Download the latest maven binaries
a. cd into the /tmp directory on your terminal
b. Check https://maven.apache.org/download.cgi and copy the link for the “Binary tar.gz archive” file.
c. Run the following command to download the binaries:
wget https://dlcdn.apache.org/maven/maven-3/3.9.6/binaries/apache-maven-3.9.6-bin.tar.gzd . Untar the archive file and extract it in the directory
tar -xvf apache-maven-3.9.6-bin.tar.gz
mv apache-maven-3.9.6 mavenmv maven /usr/share/Note: the latest maven version I was downloading was 3.9.6. Make sure to replace the version in the commands above with the maven version







