Friday, December 13, 2013

Fix Maven Error: JAVA_HOME is not defined correctly on Mac OSX 10.9 Mavericks

If your JAVA_HOME env.variable is set correctly then 100500% 
you have to hardcode the $M2_HOME/bin/mvn script!


Ok. Here is the error massege itself:
Error: JAVA_HOME is not defined correctly. We cannot execute /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home/bin/java

Now Edit mvn script (it could be line 61):
Change the path of JAVA_HOME that starts with /System/... on your e.g. /Library/...
Change above the value of variable JAVA_VERSION on that you have e.g. jdk1.7_...

Why this issue took place is beacouse the path of JAVA_HOME in OSX 10.9 Maericks is different then it was in previous versions of OS. Before it was installed in /System... now it is in /Library.... BUT the maven script still sets the path of JAVA_HOME that starts in /System... Maybe in next version of Maven this will be changed. 

That's all.