This article is transferred from: http://wenshao.iteye.com/blog/986658
First of all, I declare that this is not original. It is only posted here for the convenience of my friends and me in the future.
The implementations provided by the JDK in MacX and Oracle JDK (original SUN JDK) are very different. One of them is that there is no tools.jar, and the contents of Oracle JDK tools.jar are already included in classes.jar.
I thought of a simpler way, but I haven't tried it successfully, so I won't list it here.
<profiles> <profile> <id>default-profile</id> <activation> <activeByDefault>true</activeByDefault> <file> <exists>${java.home}/../lib/tools.jar</exists> </file> </activation> <properties> <toolsjar>${java.home}/../lib/tools.jar</toolsjar> </properties> </profile> <profile> <id>mac-profile</id> <activation> <activeByDefault>false</activeByDefault> <file> <exists>${java.home}/../Classes/classes.jar</exists> </file> </activation> <properties> <toolsjar>${java.home}/../Classes/classes.jar</toolsjar> </properties> </profile> </profiles> <dependencies> <dependency> <groupId>com.sun</groupId> <artifactId>tools</artifactId> <version>1.6.0</version> <scope>system</scope> <systemPath>${toolsjar}</systemPath> </dependency> </dependencies>