Solution one: With maven fetching runtime parameters, Eclipse provides environment variables that 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 doesn't work, $ (java.home) Eclipse resolves the wrong, eclipse does not use java_home default, Eclipse uses C: "Windows" System32 "Javaw.exe as the JVM, Of course I can't find Tools.jar.
The workaround is as follows: Modify the Eclipse.ini specified VM under the Eclipse.exe directory, note that there is no space behind-VM.
- -vm
- D:\Program Files\java\jdk1. 6.0_23\bin\javaw.exe
- -vmargs
- -dosgi.requiredjavaversion=1.6
- -xms40m
- -xmx512m
- -xx:permsize=64m
- -xx:maxpermsize=512m
Note: To write in two lines, write on a line that does not take effect
Note: These two lines will not be valid until-vmargs.
Solution Two:
- <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>
Set by profile to make it easy to decide whether to enable solution three:
- <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 the environment variables for your system directly using MAVEN
Eclipse Maven Engineering Missing Artifact Com.sun:tools:jar:1.7.0:system workaround