I am on windows environment and using maven to compile my project. Although I just created the project and added the dependencies for various libararies.
As I added them maven started complaining for the missing tools.jar
, so i added below to my pom.xml
:
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.6</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
When i ran the maven install, i got an error for the missing jar as below :
[ERROR] Failed to execute goal on project GApp: Could not resolve dependencies for project GApp:GApp:war:0.0.1-SNAPSHOT: Could not find artifact com.sun:tools:jar:1.6 at specified path C:\Program Files\Java\jre6\lib\tools.jar -> [Help 1]
The issue is that the tools.jar
is in "C:\Program Files\Java\jdk1.6.0_26\lib
" and is correctly set in the JAVA_HOME
environment variable but the maven is still looking in jre folder as in error message "C:\Program Files\Java\jre6\lib\tools.jar
".
C:\>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.6.0_26
Interestingly: when i set the full path in dependency, it worked just fine. But i don't want to hard code it.
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.6</version>
<scope>system</scope>
<systemPath>C:\Program Files\Java\jdk1.6.0_26\lib\tools.jar</systemPath>
</dependency>
Can someone suggest any dynamic solution for this?