简体   繁体   中英

Eclipse says jre does not support the current compiler level of 1.8 but it is set at 1.7

I installed Eclipse mars with java JDK8 but was was having lots of problems with it so I uninstalled it changed back to JDK7 and now I'm getting a strange compiler error in a few of my projects. I noticed that when I went into, Windows->Preferences-> Java->Installed JREs, there is an error message at the top saying that "The selected JRE does not support the ...rent compiler compliance level of 1.8" but when I check the compiler compliance level its set to 1.7

Ok so I decided to try starting a new project and when trying to build it a warning came up that my workspace compliance level was at level 1.8...changing the workspace fixed the problem. So new is it possible to change the workspace compliance level or should I just import my projects into a new workspace?

I tried importing into a new workspace,same problem. So I started new project in a new workspace, copyed and pasted the code in a voila it works! Very annoying if I have to do that for every class in every project I want.

Check your compliance settings in:

Preferences > Java > Compiler

Make sure the default is set to 1.7 as it may have defaulted to 1.8 after the initial install/run.

Also check project-specific compliance settings in:

(Project) Properties > Java Compiler

If you already changed all settings to 1.7 (both in the eclipse preferences and the project properties) check your project's build path. How? Easy, after you've imported your project, right-button click it and select Build path > Configure Build Path. Then, check if you have your JRE system library correctly set.

If even this is set up ok, I would say that you probably have some code that can only be compiled by jdk 8 and you're trying to use jdk7 compliance level, which eclipse warns you about. An example of this is using lambda functions, which can only be compiled with java 8 as far as I know .

I changed Windows ->Preference->Java->Installed JREs to jdk1.7.0_79 and right clicked the project, Properties ->Java Build Path, made sure that under Libraries tab, it is JRE System Library[JavaSE-1.7]. Clicked Project ->Clean. Right clicked the project again, Properties ->Java Compiler, checked Use compliance from execution environment 'JavaSE-1.7' on the 'Java Build Path'.Then it worked. 在此输入图像描述

I have similar issue with Mars on Pydev environment. Seems that Mars want java jre 1.7.0, so for me was work by copy inside(create if not avaiable) eclipse\\jre\\ folder and copy the 1.7.0 version of jre inside

  1. Go to Windows >> Preferences>>Compiler >> Unselect default compliance settings >> select the compiler compliance level to 1.8

  2. This should reflect in generated .class files compatibility as 1.8 and source compatibility as 1.8 Step Step

  3. Apply it Step

  4. now click on apply and close

  5. clean and build the project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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