Search code examples
maven-232bit-64bitjavawindows-7-x64

Maven 2.2.1 on Windows 7 64-bit


For various reasons, I must stick with older versions of Java (6) and Maven (2.2). So with that I mind, I installed Maven 2.2.1 while my system uses the 64-bit JDK 6.

I tried to verify that it is correctly installed by running mvn --version and what I received in response was:

ERROR: JAVA_HOME is set to an invalid directory.
JAVA_HOME = "C:\Windows:\Program Files\Java\jdk1.6.0_37"
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation

I am suspecting that Maven expects the 32-bit version of Java and that it cannot deal with 64-bit Java. Is this true?

If indeed this is the case, setting the %JAVA_HOME% environment variable to point the 32-bit version (already installed) is not what I would like to do because it will then fail other tools installed on my PC that count on it pointing to the 64-bit version.

Is there a way around this?

UPDATE: Problem solved by inserting into maven.bat the following line (just before === START VALIDATION ===):

set JAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_37

This way, this %JAVA_HOME% environment change is localized to Maven and is not visible outside.

If there is a better solution, I would be happy to know about it.


Solution

  • The source of the problem was in front of my eyes all that time but I didn't see it:

    The %JAVA_HOME% env var was set to %SystemRoot%\Program Files (x86)\Java\jdk1.6.0_37 instead of %SystemDrive%\Program Files (x86)\Java\jdk1.6.0_37.

    Once fixed, no modification of maven.bat is required.