Error: Could not find or load main class org.codehaus.classworlds.Launcher while building Maven 3.0.4

Viewed 23530

I have used apt-get install maven2 to install maven2.2.1. In order to compile hadoop 2.1.0 source program, I need to upgrade the maven version, but it is not able to use apt-get again, because maven2.1.0 is the latest in the lib.

I downloaded apache-maven-3.0.5-bin.tar.gz from the official website, ran tar apache-maven-3.0.5-bin.tar.gz at the path /usr/local, and put apache-maven links to apache-maven-3.0.5:

lrwxrwxrwx  1 root root   18 Dec  8 11:26 apache-maven -> apache-maven-3.0.5
drwxr-xr-x  6 root root 1024 Dec  8 11:12 apache-maven-3.0.5

export the order in the terminal like this:
export M2_HOME=/usr/local/apache-maven
export PATH=$PATH:$M2_HOME/bin 

input order "export" to identify :

.............................................
declare -x M2_HOME="/usr/local/apache-maven"
declare -x MANDATORY_PATH="/usr/share/gconf/ubuntu.mandatory.path"
declare -x OLDPWD="/usr"
declare -x PATH="/usr/lib/lightdm/lightdm:/usr/local/java/latest/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/apache-maven/bin"

All signs showed maven 3.0.5 has succeeded in configuration, but when I input

mvn -version

in the terminal, it show errors like this:

Error: Could not find or load main class org.codehaus.classworlds.Launcher

If I change a new terminal and input mvn -version, it shows:

administrator@ubuntu:~$ mvn -version
Apache Maven 2.2.1 (rdebian-8)
Java version: 1.7.0_45
Java home: /usr/local/java/jdk1.7.0_45/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" version: "3.5.0-17-generic" arch: "amd64" Family: "unix"

It happens every time although I had uninstalled maven 2.2.1 by running:

sudo apt-get remove --purge maven

I do not know why? I have not uninstalled it completely?

5 Answers

Solved for me on Ubuntu 18.04:

$ sudo apt-get remove maven

$ sudo apt-get purge maven

$ sudo apt-get install maven
Related