Search code examples
maven-2java-home

weird problem with JAVA_HOME and maven dependencies


I have JAVA_HOME variable set to C:\Program Files\Java\jre6\ when I run maven package on the project it tells me that it can't resolve dependency

[ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.0:compile (default) on project roo: Execution default of goal o
rg.codehaus.mojo:aspectj-maven-plugin:1.0:compile failed: Plugin org.codehaus.mojo:aspectj-maven-plugin:1.0 or one of its dependencies
could not be resolved: Could not find artifact com.sun:tools:jar:1.4.2 at specified path C:\Program Files\Java\jre6/../lib/tools.jar ->
[Help 1]

so it assumes that JAVA_HOME is actually one level deeper than it actually is, I have looked through maven local repository and found that log4j 1.2.16 uses this dependency

I tried to make JAVA_HOME look like C:\Program Files\Java\jre6\bin\ but then maven wouldnt run, it told me that my JAVA_HOME path was wrong


Solution

  • You will need a Java JDK not just a JRE. You can get one at Oracle's Java Page

    Edit: From the Maven Properties Guide:

    ${java.home} specifies the path to the current JRE_HOME environment use with relative paths to get for example:
    <jvm>${java.home}../bin/java.exe</jvm>
    

    And with a JDK for example in c:\jdk the maven ${java.home} is pointing to c:\jdk\jre