Y0gesh Gupta
Y0gesh Gupta

Reputation: 2204

Pom.xml project build error

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

Answers (4)

fwhdzh
fwhdzh

Reputation: 51

Sam Hanes' answer is great. However, there are two points:

  1. ${java.home} represents the installation directory for JRE, which is sometimes different from the installation directory for JDK. And the tools.jar is usually at "INSTALLATION_DIRECOTRY_OF_JDK"/lib/tools.jar
  2. If you use ${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

lighk
lighk

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

Sam Hanes
Sam Hanes

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

Doss
Doss

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

Related Questions