Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven error in MINGW Git bash: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher

I'm aware of the fact that this issue has been discussed in several questions but no answer solved my specific issue.

I have installed Git bash and Maven and I'm trying to execute Maven with Git bash. It aborts with the mentioned error.

My system environment:

Windows 7
Git 2.13.3
Maven 3.5.0

The required user variables:

HOME=%HOMEPATH%
M3_HOME=%MAVEN_HOME%
MAVEN_HOME=path-with-no-blanks
Path=%MAVEN_HOME%\bin

Maven works fine on Windows command prompt and Cygwin. Only MINGW-based Git bash fails.

I examined the bash script mvn under: C:\path\to\maven\bin

By setting log outputs and by checking when MAVEN_HOME value gets lost I found out that it gets cleared by these statements (even JAVA_HOME):

# For MinGW, ensure paths are in Unix format before anything is touched !!!HERE MAVEN_HOME value is getting lost!!!
if $mingw ; then
  [ -n "$MAVEN_HOME" ] &&
    MAVEN_HOME=`(cd "$MAVEN_HOME"; pwd)`
  [ -n "$JAVA_HOME" ] &&
    JAVA_HOME=`(cd "$JAVA_HOME"; pwd)`
  # TODO classpath?
fi

On another Windows machine (different version of Maven and Git) the same lines are a bit different:

M2_HOME="`(cd "$MAVEN_HOME"; pwd)`"

instead of:

MAVEN_HOME=`(cd "$MAVEN_HOME"; pwd)`

First, I thought it's due to the kind of quotation characters. But the working Windows machine even runs well with the new script from my failing Windows machine. I also tried to install the old Git or an older Maven - nothing helps.

Why does the mentioned bash script line clears the MAVEN_HOME variable?

like image 514
PAX Avatar asked Jul 29 '17 15:07

PAX


1 Answers

I was getting the exact same error for a while until I realized that it was being cause by my antivirus (Comodo). Git bash would not work properly even if I had exited/disabled Comodo.

So if you have Comodo, try following these steps to fix the error (if you don't then maybe try performing something similar with whatever antivirus/firewall you are using):

  1. Comodo->Settings->File Rating-> Add Folder (Git Folder). This ended up adding over 5000 trusted files (but it helped fix the issue).

  2. Comodo->Settings->Advanced Protection->Miscellaneous-> and find the checkmark "Don't detect shellcode injections in...". I added the entire Git Folder to shellcode injections.

  3. I set the git folder to "ignore" in Comodo->Settings->containment->"Auto-containment"

I'll add that I'm not sure if all of the steps are required, so feel free to perform them one by one and see which helps.

like image 184
letowianka Avatar answered Sep 23 '22 15:09

letowianka