简体   繁体   English

带有M2e的Eclipse Mars无法更改Java编译路径

[英]Eclipse Mars with m2e can not change java compile path

While trying to do a maven compile goal on a jar project in eclipse it failed stating that there was no java compiler found. 尝试在Eclipse中的jar项目上执行maven编译目标时,它失败,指出没有找到Java编译器。 It showed that it was using the path to jre1.8.0_45. 它表明它正在使用jre1.8.0_45的路径。 My configured java build path in eclipse is using jdk1.7.0_80 and is configured for the correct corresponding environment. 我在eclipse中配置的Java构建路径使用的是jdk1.7.0_80,并且已针对正确的相应环境进行了配置。

I tried to rename the jre directory while eclipse was open but it showed that something had a lock on it, and sure enough it was eclipse that was launching with jre1.8. eclipse打开时,我尝试重命名jre目录,但它表明存在某些锁定,并且可以肯定的是使用jre1.8启动的eclipse。 If I renamed the jre1.8 directory while eclipse was closed, then it would not launch again complaining that it cant find the java directory. 如果我在eclipse关闭时重命名了jre1.8目录,则它不会再次启动,并抱怨找不到Java目录。

I guess what I'm getting at here is, is this a bug with Mars? 我想我在这里得到的是,这是火星的错误吗? Or am I missing something because everything in Eclipse is pointed to 1.7. 还是我错过了某些东西,因为Eclipse中的所有内容都指向1.7。

Thanks, Nate 谢谢,内特

You should point Eclipse to JDK installation. 您应该将Eclipse指向JDK安装。

Window -> Preferences -> Java\\Installed JREs click Add -> Select Standard VM, Next -> and then in text box "JRE home" you should put path to JDK home, it's quite misleading.. 窗口->首选项-> Java \\已安装的JRE,单击添加->选择标准VM,然后单击下一步->,然后在文本框“ JRE home”中放置JDK home的路径,这很容易引起误解。

BTW you should specify java version in maven-compiler-plugin. 顺便说一句,您应该在maven-compiler-plugin中指定Java版本。 M2E plugin will then recognize this settings and configure compiler appropriatelly 然后,M2E插件将识别此设置并适当地配置编译器

http://www.gamefromscratch.com/post/2011/11/15/Telling-Eclipse-to-use-the-JDK-instead-of-JRE.aspx http://www.gamefromscratch.com/post/2011/11/15/Telling-Eclipse-to-use-the-JDK-instead-of-JRE.aspx

It's the launch configuration of any m2e build that should point to a full JDK, cf. 这是任何m2e构建的启动配置,都应指向完整的JDK,请参见。 http://help.eclipse.org/mars/topic/org.eclipse.jdt.doc.user/tasks/task-choose_config_jre.htm?cp=1_3_5_2 (except you will be using a Maven Build configuration, rather than a Java Application). http://help.eclipse.org/mars/topic/org.eclipse.jdt.doc.user/tasks/task-choose_config_jre.htm?cp=1_3_5_2 (除非您将使用Maven Build配置,而不是Java应用)。

For most other situations using a JRE should be perfectly fine. 对于大多数其他情况,使用JRE应该很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM