Reputation: 2204
I have imported maven projects in my eclipse, but I am getting the following error in pom.xml-
Project build error: 'dependencyManagement.dependencies.dependency.systemPath' for jdk.tools:jdk.tools:jar must specify an absolute path but is ${JAVA_HOME}/lib/tools.jar
I am kind of new to maven, any help will be appreciated.
Upvotes: 4
Views: 14377
Reputation: 51
Sam Hanes' answer is great. However, there are two points:
"INSTALLATION_DIRECOTRY_OF_JDK"/lib/tools.jar
${env.JAVA_HOME}
and you are in linux, be sure that you have correctly exported JAVA_HOME
environment variable. You can use export
command in bash to see whether there is a line like declare -x JAVA_HOME=....
. In particular, you should write your .bash_profile or .bash_rc like: export JAVA_HOME=THE_DIRECOTRY_OF_YOU_JDK
export PATH="$JAVA_HOME/bin:$PATH"
instead of
JAVA_HOME=THE_DIRECOTRY_OF_YOU_JDK
PATH="$JAVA_HOME/bin:$PATH"
If you miss export
in your .bash_profile or .bash_rc, you can still use $JAVA_HOME
in your bash terminal. However, Maven cannot recognize what env.JAVA_HOME
means.
Upvotes: 0
Reputation: 11
This is due to a lack of Maven property —— JAVA_HOME
. You can add it to your pom.xml
<properties>
<!-- your java home -->
<JAVA_HOME>/opt/java/jdk1.8.0_202</JAVA_HOME>
</properties>
Upvotes: 0
Reputation: 2849
You've specified a dependency on jdk.tools:jdk.tools:jar
with a <systemPath>
of ${JAVA_HOME}/lib/tools.jar
. ${JAVA_HOME}
is not a valid Maven property. The syntax to read the environment variable JAVA_HOME
is ${env.JAVA_HOME}
. However, the same information is exposed as a system property named java.home
, so ${java.home}
is the best solution.
Upvotes: 16
Reputation: 31
Look for tools.jar
which should be in jdk/lib
, if not mean download latest jdk or add tools.jar
to this location. This should fix the issue.
Upvotes: -4