Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven with Cygwin - Error: JAVA_HOME is not defined correctly

Tags:

java

maven

cygwin

I'm trying to run Maven on cygwin. I've added maven to the path and my Java home looks like this:

$ echo $JAVA_HOME 
/cygdrive/c/Program Files/Java/jdk1.6.0

Yet when I try to run mvn --version, I get this:

Error: JAVA_HOME is not defined correctly.
  We cannot execute /cygdrive/c/Program Files/Java/jdk1.7.0_01/bin/java

Any idea why it's not working? Java -version works fine, so it's not a problem with java. I've also tried jdk1.6.0 instead.

Running which java gives,

$ which java
/cygdrive/c/windows/system32/java

and java -version gives,

$ java -version
java version "1.7.0_01"
Java(TM) SE Runtime Environment (build 1.7.0_01-b08)
Java HotSpot(TM) Client VM (build 21.1-b02, mixed mode, sharing)
like image 809
gsingh2011 Avatar asked Dec 15 '11 17:12

gsingh2011


1 Answers

If I run mvn.bat instead of mvn, I didn't have this problem.

So, since Cygwin will run the mvn file, I replaced this mvn file with a softlink (ln -s mvn.bat mvn) to the batch file. This way, running mvn will silently run the mvn.bat which handles these problems gracefully.

like image 54
Stefan De Laet Avatar answered Oct 27 '22 21:10

Stefan De Laet