13

My eclipse reported the warning that "The compiler compliance specified is 1.6 but a JRE 1.8 is used".

I have built my HelloWorld Android application using Java1.8, however, I got that warning and I cannot build up my project. I have tried to set the compiler compliance to java1.8. But I got another error that

"Android requires compiler compliance level 5.0 or 6.0. Found '1.8'"

.I don't know how to fix this problem?

Romil Patel
  • 12,879
  • 7
  • 47
  • 76
Jessie
  • 131
  • 1
  • 1
  • 3
  • 3
    I had a similar issue with a Maven project (nothing related to Android) and Patel Romil's second suggestion below did the trick! – Olivier Jan 27 '20 at 10:13

4 Answers4

19

Possible solution:

  1. Right-click on your project and select "Android Tools -> Fix Project Properties". (if this doesn't work, try the following option)
  2. Right-click on your project and select "Properties -> Java Compiler", check "Enable project specific settings" and select 1.5 or 1.6 from the "Compiler compliance settings" select box.
  3. Under Window -> Preferences -> Java -> Compiler, set Compiler compliance level to 1.5 or 1.6.
Olivier
  • 303
  • 3
  • 14
Romil Patel
  • 12,879
  • 7
  • 47
  • 76
  • I have tried this but it did not work. I still got the error :Errors running builder 'Android Package Builder' on project 'HelloWorld'. sun/misc/BASE64Encoder – Jessie May 30 '19 at 05:47
  • 1
    @Jessie as from the information The compiler compliance specified is 1.6, so please recheck all properties are with 1.6 if errors are still there, update with the errors – Romil Patel May 30 '19 at 05:57
  • I have rechecked the properties, and I think all is 1.6. And I still get warned that "The compiler compliance specified is 1.6 but a JRE 1.8 is used" and I cannot build my project with the error "Errors running builder 'Android Package Builder' on project 'HelloWorld'.sun/misc/BASE64Encoder" – Jessie May 30 '19 at 06:18
  • 1
    @Jessie In Eclipse, go to Window > Preferences > Installed JREs > Execution Environment and select JavaSE 1.6 (it should be there) and select jdk1.6 and restart the eclipse – Romil Patel May 30 '19 at 06:24
  • @Jessie Additionally, eclipse.ini also has a reference to the Java VM it uses. Make sure the VM it points to is Java 1.6 (see link on how to find it and how to set VM preferences). https://wiki.eclipse.org/Eclipse.ini – Romil Patel May 30 '19 at 06:28
  • This happened to me too, using Eclipse 2021-12 on Debian 11. Merely going into `Window -> Preferences -> Java -> Compiler` and flipping the `Compiler compliance level` to (1.4 or something) and immediately back to 11 fixed the warning. – JonathanDavidArndt Jan 23 '22 at 03:40
2

I'm working on VSCode and I just made next thing I changed version in pom.xml to one I installed on computer.

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.11</maven.compiler.source>
    <maven.compiler.target>1.11</maven.compiler.target>
    <java.version>1.11</java.version>
</properties>

Before I had 1.8 and now there is 1.11.

user16217248
  • 3,119
  • 19
  • 19
  • 37
sedub01
  • 71
  • 6
0

Go to windows>preference>java>compiler. Tick the check box "use default compliance setting" then apply and close. Right-click on the project and go to build path> configure build the path Under Libraries tab remove JRE System Library and click on add library select the radio box execution environment and select the environment Apply nad Close

0

Following changes need to be done under folder name of your project: -

.settings

eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.processAnnotations=disabled
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8

IDE configuration

S Satyen
  • 31
  • 3