Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resource specification not allowed here for source level below 1.7

Tags:

java

While running java program getting following error in eclipse

Caused by: java.lang.Error: Unresolved compilation problem: 
    Resource specification not allowed here for source level below 1.7

Although I am using java 1.7.25 and all eclipse settings are in place but not sure why getting this error

SOLUTION.

Problem solved by updating project in eclipse using maven.

like image 623
big Avatar asked Dec 27 '13 19:12

big


2 Answers

Despite of the fact that you are using Java 1.7 you can compile source code as if you had compiler from Java 1.6 (this can be useful for example for cross-compilation). As Shivam Tiwari said in Eclipse you can change it in window->preferences->java->Compiler Compiler

If you are using Maven you should add the following plugin:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>2.5.1</version>
  <configuration>
    <source>1.7</source>
    <target>1.7</target>
  </configuration>
</plugin>
like image 81
Ivan Mushketyk Avatar answered Nov 13 '22 11:11

Ivan Mushketyk


In Eclipse. Go to Project->Properties->Click on Java Compiler and change Compiler compliance level to 1.8 or above. It works for me many times.

like image 2
Ankush Supnar Avatar answered Nov 13 '22 12:11

Ankush Supnar