在Java项目的pom.xml中,我丢失了工件jdk.tools:jdk.tools:jar:1.6错误

问题描述:

我想我知道如何解决该问题,除了:我不知道特定版本在pom中所指的位置(我没有明确看到它),而我所看到的解决方案是添加此依赖项: /p>

I think I know how to solve the problem except: I don't know where in the pom the specific version is referred to (I do not see it explicitly) and the solution I have seen is to add this dependency:

<dependency>
   <groupId>com.sun</groupId>
   <artifactId>tools</artifactId>
   <version>1.6</version>
   <scope>system</scope>
   <systemPath>C:\Program Files\Java\jdk1.6.0_29\lib\tools.jar</systemPath>
 </dependency>

但是我想使用com.oracle,Windows上的jdk目录是jdk1.8.

But I would like to use com.oracle and the jdk directory on Windows is jdk1.8.

那么有什么方法可以使pom想要"我在计算机上实际拥有的工具版本?

So is there a way to make the pom "want" the version of tools that I actually have on my machine?

我终于以正确的方式解决了这个问题.

I finally tackled this the proper way.

当使用JRE而不是JDK启动Eclipse时会发生这种情况,因为tools.jar不在JRE中. 根据该声明,尝试安装JDK.如果已经安装,请在您的Path中检查是否具有JDK路径而不是JRE路径.

This happens when eclipse is launched with the JRE instead of the JDK as tools.jar isn't in the JRE. Based on that assertion, try installing the JDK. If it's already installed, check in your Path that you have the JDK path and not the JRE path.

请注意,最新的Java版本似乎在Path中添加了以下目录:C:\ProgramData\Oracle\Java\javapath.它包含可能链接到JRE的快捷方式.您将要删除它,并将链接添加到您的JDK bin文件夹. (例如C:\Program Files\Java\jdk1.8.0_66\bin)

Be careful, the latest versions of java seems to add in the Path the following directory: C:\ProgramData\Oracle\Java\javapath. It contains shortcuts that may link to the JRE. You'll want to remove that and add in the link to your JDK bin folder. (e.g. C:\Program Files\Java\jdk1.8.0_66\bin)

请注意,您可能需要重新启动计算机才能使Path中的更改对日食启动有效(我不太了解为什么要这么做,但我确实这样做了.).

Note that you may need to restart your computer for the changes in the Path to be effective for the eclipse launch (I don't really understand why I had to but I did).

还请注意,Java更新可能会将javapath重新添加到您的PATH中.因此,您可能不想使用自动更新,而是手动更新JDK并在安装后调整路径.它有点沉重,但可以完成工作.

Also note that Java updates will probably re-add the javapath to your PATH. So you may want not to use auto-updates but instead manually update your JDK and adapt your path after the install. It's a bit heavy but does the work.