Solution 1
The runtime parameters obtained through Maven are the environment variables provided by ECLIPSE, which are basically similar to system. getproperty ("Java. Home ")
<dependency> <groupId>com.sun</groupId> <artifactId>tools</artifactId> <version>1.5.0</version> <scope>system</scope> <systemPath>${java.home}/lib/tools.jar</systemPath> </dependency>
If it does not work, it is because $ {java. Home} is playing a strange role. Eclipse
Java_home is not used
By default, eclipse
C: "Windows" System32 "javaw.exe is used as JVM. Of course, tools. Jar cannot be found.
The solution is as follows: Modify eclipse. ini in the eclipse.exe directory to specify the VM. Note that there is no space behind the VM.
-vmD:\Program Files\Java\jdk1.6.0_23\bin\javaw.exe-vmargs-Dosgi.requiredJavaVersion=1.6-Xms40m-Xmx512m-XX:PermSize=64M-XX:MaxPermSize=512M
Note: Two lines must be written, and one line cannot take effect.
Note: These two lines must be before-vmargs, otherwise they will not take effect.
Solution 2:
<properties> <project.build.sourceEncoding>UTF8</project.build.sourceEncoding> <java.home>C:\Program Files\Java\jdk1.6.0_25</java.home> </properties> <profiles> <profile> <id>default-tools.jar</id> <activation> <activeByDefault>true</activeByDefault> <property> <name>java.vendor</name> <value>Sun Microsystems Inc.</value> </property> </activation> <dependencies> <dependency> <groupId>com.sun</groupId> <artifactId>tools</artifactId> <version>1.5.0</version> <scope>system</scope> <systemPath>${java.home}/lib/tools.jar</systemPath> </dependency> </dependencies> </profile> </profiles>
You can use profile to determine whether to enable solution 3:
<dependency> <groupId>com.sun</groupId> <artifactId>tools</artifactId> <version>1.6.0</version> <scope>system</scope> <systemPath>${env.JAVA_HOME}/lib/tools.jar</systemPath> <optional>true</optional> </dependency>
Get system environment variables directly using Maven