• Register
0 votes
299 views

Problem :

I am stuck with following Maven issue.

Error: could not find or load main class org.codehaus.plexus.classworlds.launcher.launcher      

My Maven was working fine till last week after that I do not know what went wrong with it now it gives me the error I have tried replacing M2_HOME path with M3_HOME and also MAVEN_HOME. But nothing is working for me. I am using OS X. Following is the output of few maven commands. Let me know if you know the solution for my error:

$ mvn

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

$ which mvn

/Library/Maven-3.3.3/bin/mvn

$ echo $M2_HOME

/Library/Maven-3.3.3

$ echo $JAVA_HOME

/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home

$ which java

/usr/bin/java

$ /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/bin/java -version

java version "1.7.0_75"

Java(TM) SE Runtime Environment (build 1.7.0_75-b13)

Java HotSpot(TM) 64-Bit Server VM (build 24.75-b04, mixed mode)

$ echo $PATH

/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Tomcat/bin:/Library/Maven-3.3.3/bin

$ java -version

java version "1.7.0_75"

Java(TM) SE Runtime Environment (build 1.7.0_75-b13)

Java HotSpot(TM) 64-Bit Server VM (build 24.75-b04, mixed mode)

6 5 3
7,540 points

Please log in or register to answer this question.

2 Answers

0 votes

Solution :

Remove your M2_HOME as the environment variable, as it is already set by the mvn script. The only things remaining are: To add apache-maven-3.x.x/bin to your path and set JAVA_HOME as environment variable. And also no need to add %JAVA_HOME%/bin to your path

Please run mvn -v from /Library/Maven-3.3.3/bin/ folder first to confirm your installation is correct. Also try to run mvn with xtrace info and also verify the command line built up by Maven. I assume you get an unexpected class path argument value.

9 7 4
38,600 points
0 votes

Solution:

 For Maven3, changing my environment variable name from M2_HOME to M3_HOME did the trick. I am on a Mac running OSX 10.9 with JDK 1.7.

Please remove M2_HOME as environment variable, it is already set by the mvn script. The only things you need to do is: add apache-maven-3.x.x/bin to your path, set JAVA_HOME as environment variable. So no need to add %JAVA_HOME%/bin to your path

Try to run mvn -v from /Library/Maven-3.3.3/bin/ folder first to confirm the installation is correct. Try to run mvn with xtrace info (tldp.org/LDP/Bash-Beginners-Guide/html/sect_02_03.html) and verify the commandline built up by Maven. I assume you get an unexpected classpath argument value.

EDIT : Note this is for Mac users

M2_HOME needs to be removed from the PATH. By default, your PATH might be picked up from one of the following files (for me, it was in ~/.profile).

Code:

/etc/bashrc
/etc/profile
~/.bashrc
~/.bash_profile
~/.profile
~/.MacOSX/environment.plist

It might look something like this:

export M2_HOME=/Applications/apache-maven-3.2.3
export M2=$M2_HOME/bin
export PATH=$M2:$PATH

Remove the M2_HOME variables, and any dependencies (in the example, the M2 variable uses M2_HOME, so remove that, and the line after which uses $M2) where ever it shows up.

Just to give more info on how this file is used, you can keep appending whatever location you want to include in the path

For instance, if you want to include /User/batman/google-sdk into path, then adding the below line to the end of the file will append /Users/batman/google-sdk (in your case whatever the location of the folder is), to the PATH.

export PATH=$PATH:/Users/batman/google-sdk.

But make sure the PATH already has some info before the above line.

10 6 4
31,120 points

Related questions

0 votes
1 answer 4 views
4 views
Problem: I am just getting the critical error message of (could not find or load main class org.apache.hadoop.mapreduce.v2.app.mrappmaster). Does anyone know how to fix it?
asked Mar 30 zayed1 24.7k points
0 votes
1 answer 15 views
15 views
Problem: How can I fix this problem: Error: could not find or load main class org.apache.catalina.startup.bootstrap .
asked Mar 14 Wafa Abu Yousef 6.1k points
0 votes
1 answer 1.8K views
1.8K views
Problem : When I run the apache tomcat7.0.56 in Eclipse, I get below error Error: Could not find or load main class org.apache.catalina.startup.Bootstrap How can I fix the above problem?
asked Jan 18, 2020 jwilliam 3.9k points
0 votes
1 answer 9 views
9 views
Problem: How to fix the error: could not find or load main class org.testng.remote.remotetestng?
asked Mar 27 ashik 10.7k points
0 votes
1 answer 61 views
61 views
Problem: error: could not find or load main class org.testng.testng.
asked Feb 20 charles mathews 5.5k points
0 votes
1 answer 2.6K views
2.6K views
Problem : I cleaned my whole project by deleting my local directories as following ~/.gradle, ~/.m2 ~./android and ~/workspace/project/.gradle and choosing the File -> Invalidate Caches / Restart... in my Android Studio. Now execution of my command ./gradlew leads to the ... say that I deleted too much code, the question now is how can it be repaired again? Do you have any solution to fix this?
asked Jan 18, 2020 jwilliam 3.9k points
1 vote
1 answer 39 views
39 views
Problem: From a test suite using TestNG . I have included only one test.java file for my service. I have created the testng.xml file as well but ... It could not find or load main class org.testng.remote.remotetestng
asked Feb 24 Sofia Castro 4.2k points
0 votes
1 answer 1 view
1 view
Problem: Do you have any ideas about how I would be able to fix this problem,"error: could not find or load main class linux."
asked 22 hours ago Humaira ahmed 8.1k points
0 votes
1 answer 3 views
3 views
Problem: What caused the error, " Error: could not find or load main class hello " ?
asked 1 day ago zayed1 24.7k points