I have cygwin in Windows 7 and downloaded and installed maven \"binaries\" and have the following set
export JAVA_HOME=/cygdrive/c/java/jdk1.7.0_11
export MA
change the JAVA_HOME path in .bashrc_profile file
Maven with Cygwin - Error: JAVA_HOME is not defined correctly
The "alias mvn=mvn.bat" answer toward the bottom of above post worked for me. However, is this THE solution?
I spent a couple of hours fruitlessly fiddling with different combinations of JAVA_HOME, M2_HOME and M2 after this same problem. Finally I set down to debugging the mvn script (by changing line 1 to read "#!/bin/sh -x
"). It occurs because the script is relying on shell globbing to get the correct version of the .jar file (at approx. line 157):
CLASSPATH="${M2_HOME}/boot/plexus-classworlds-*.jar"
the * is not being expanded, for some reason globbing is disabled; Hence the command the script attempts to execute is:
'/cygdrive/c/Program Files/Java/jdk1.7.0_40/bin/java' -classpath 'D:\apps\apache-maven-3.0.4\boot\plexus-classworlds-*.jar' '-Dclassworlds.conf=D:\apps\apache-maven-3.0.4\bin\m2.conf' '-Dmaven.home=D:\apps\apache-maven-3.0.4' org.codehaus.plexus.classworlds.launcher.Launcher -version
when it should be:
'/cygdrive/c/Program Files/Java/jdk1.7.0_40/bin/java' -classpath 'D:\apps\apache-maven-3.0.4\boot\plexus-classworlds-2.4.jar' '-Dclassworlds.conf=D:\apps\apache-maven-3.0.4\bin\m2.conf' '-Dmaven.home=D:\apps\apache-maven-3.0.4' org.codehaus.plexus.classworlds.launcher.Launcher -version
Solution: Edit the "mvn" script and change line 157 to read:
CLASSPATH="$(echo ${M2_HOME}/boot/plexus-classworlds-*.jar)"