Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 358
michael nesterenko Avatar asked Mar 19 '11 02:03

michael nesterenko


People also ask

Does Maven require JAVA_HOME?

Maven always uses the JDK specified by JAVA_HOME , no matter how many JDK installations are available on the system. This allows the user the flexibility to change JDKs as required or based on the project.


2 Answers

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

like image 161
moritz Avatar answered Oct 12 '22 22:10

moritz


I also found this that helped me out.

... With Eclipse, you need to verify that Installed JREs are using JDK installs.

This means that in the configuration option... Window / Preferences / Java / Installed JREs ...You should point to a JDK installation.

You need to change the path to the jre within the jdk. for %Program Files%\Java\jdk1.6.0_25\jre

like image 25
Garry Taylor Avatar answered Oct 12 '22 22:10

Garry Taylor