In Maven, $ {java.home} points to the JRE directory used by the JDK, not the JDK itself. Please check out this question:
Java_home in Maven
So instead
${java.home}/lib/tools.jar
which suggests a JDK directory that you should use
${java.home}/../lib/tools.jar
However, this is only half the solution. The problem is that on Mac the directory structure is different. You have user profiles to make your relibaly build cross-platform.
Please check out this question:
JDK tools.jar as a maven dependency
And, specifically, this answer (this is the correct answer, not the one accepted by the OP there).
This is how Oracle processes it in one of its POMs :
<dependency> <groupId>com.sun</groupId> <artifactId>tools</artifactId> <version>1.6</version> <scope>system</scope> <systemPath>${tools.jar}</systemPath> </dependency>
And then in profiles :
<profile> <id>default-tools.jar</id> <activation> <file> <exists>${java.home}/../lib/tools.jar</exists> </file> </activation> <properties> <tools.jar>${java.home}/../lib/tools.jar</tools.jar> </properties> </profile> <profile> <id>default-tools.jar-mac</id> <activation> <file> <exists>${java.home}/../Classes/classes.jar</exists> </file> </activation> <properties> <tools.jar>${java.home}/../Classes/classes.jar</tools.jar> </properties> </profile>
The Mac JDK has a different file structure. That is why you must define these profiles.
See also the following messages:
source share