Java 您需要使用 JDK 运行构建或在类路径上有 tools.jar
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27619304/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
You need to run build with JDK or have tools.jar on the classpath
提问by Pearl Jade
I'm using Eclipse Luna to develop java maven applications.
我正在使用 Eclipse Luna 开发 java maven 应用程序。
I am, or was, but am again now, using jdk1.7 as my default installed JRE.
我是,或者是,但现在又使用 jdk1.7 作为我默认安装的 JRE。
After an update from SVN that I made, I started getting this error on my pom.xml files:
从我所做的 SVN 更新后,我开始在我的 pom.xml 文件中收到此错误:
You need to run build with JDK or have tools.jar on the classpath.
If this occures during eclipse build make sure you run eclipse under JDK as well
(com.mysema.maven:apt-maven-plugin:1.0.6:process:default:generate-sources)
I noticed that my jdk1.7 installation was GONE from eclipse somehow. I've tried all the options that I've found here on stackoverflow about re-adding that jdk1.7 and setting it as my project's JRE library and even adding the tools.jar to the jdk1.7 library on eclipse, but I'm still getting the error, which makes very little sense now.
我注意到我的 jdk1.7 安装不知何故从 eclipse 中消失了。我已经尝试了我在 stackoverflow 上找到的所有关于重新添加 jdk1.7 并将其设置为我的项目的 JRE 库的选项,甚至将 tools.jar 添加到 eclipse 上的 jdk1.7 库,但我我仍然收到错误,这现在没有什么意义。
采纳答案by Henrique Ordine
Try setting this to your eclipse.ini file and restarting eclipse to make sure that it's also using your JDK:
尝试将其设置为您的 eclipse.ini 文件并重新启动 eclipse 以确保它也在使用您的 JDK:
-vm
C:\jdk1.7\bin\javaw.exe
Cautions:
注意事项:
- this must go just above
-vmargs
- you're full path to your VM maybe different than the one above
- 这必须在上面
-vmargs
- 你的虚拟机的完整路径可能与上面的不同
See thisas reference.
见这个作为参考。
回答by pmverma
By default, eclipse will uses the "C:\Program Files\Java\jre7".
默认情况下,eclipse 将使用“C:\Program Files\Java\jre7”。
Change it, to use "C:\Program Files\Java\jdk1.7.0_xx".
更改它,使用“C:\Program Files\Java\jdk1.7.0_xx”。
回答by Mehran Hassani
I had to remove JRE from my installed JREs to make it work. Go to perefrences>Java>Installed JREs, remove jre and select jdk.
我必须从我安装的 JRE 中删除 JRE 才能使其工作。转到 perefrences>Java>Installed JREs,删除 jre 并选择 jdk。
回答by Akshatha Srinivas
This small trick worked for me.
这个小技巧对我有用。
I tried creating a shortcut of eclipse on desktop. Right click -> properties -> Target
我尝试在桌面上创建 eclipse 的快捷方式。右键->属性->目标
edit the target path as follows.
编辑目标路径如下。
After .exe append the following
在 .exe 之后追加以下内容
-vm "C:\Program Files\Java\jdk1.8.0_201\bin"
this should look something like this(I was using sts)
这应该看起来像这样(我正在使用 sts)
C:\Users\User\Downloads\sts-bundle\sts-3.9.7.RELEASE\STS.exe -vm "C:\Program Files\Java\jdk1.8.0_201\bin"
Click apply
点击申请
Open the eclipse from shortcut and try.
从快捷方式打开eclipse并尝试。
回答by claraind
I did it finally! I've tried so many option like thisand this, but no luck. Then I read this commentthat saved my life, really, thank you! I follow this solution and its working suddenly! should be accepted answer in my case.
我终于做到了!我已经尝试了很多像这样和这样的选择,但没有运气。然后我看了这条救了我一命的评论,真的,谢谢!我遵循这个解决方案,它突然工作了!在我的情况下应该接受答案。
I copied tools.jar from C:\Program Files\Java\jdk1.8.0_151\lib to C:\Program Files\Java\jre1.8.0_151\lib, after i execute mvn clean install – @julio mulcue burbano
我将 tools.jar 从 C:\Program Files\Java\jdk1.8.0_151\lib 复制到 C:\Program Files\Java\jre1.8.0_151\lib,在我执行 mvn clean install 之后 – @julio mulcue burbano