Eclipse Mars with m2e can not change java compile path

879 views Asked by At

While trying to do a maven compile goal on a jar project in eclipse it failed stating that there was no java compiler found. It showed that it was using the path to 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.

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. 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.

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.

Thanks, Nate

2

There are 2 answers

1
ppysz On

You should point Eclipse to JDK installation.

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..

BTW you should specify java version in maven-compiler-plugin. M2E plugin will then recognize this settings and configure compiler appropriatelly

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

2
Stephan Herrmann On

It's the launch configuration of any m2e build that should point to a full JDK, cf. 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).

For most other situations using a JRE should be perfectly fine.