Bosco
Bosco

Reputation: 4062

maven compilation fails with error static interface methods are not supported in -source 1.7

maven is pointing to java 1.8, but maven command complains use -source 8 or higher to enable static interface methods

$mvn -version

Picked up _JAVA_OPTIONS: -Xmx2048m -XX:MaxPermSize=512m -Djava.awt.headless=true OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=512m; support was removed in 8.0 Apache Maven 3.1.0 (893ca28a1da9d5f51ac03827af98bb730128f9f2; 2013-06-27 19:15:32-0700) Maven home: /opt/apache-maven-3.1.0 Java version: 1.8.0_101, vendor: Oracle Corporation Java home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.101-3.b13.el6_8.x86_64/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "2.6.32-573.el6.x86_64", arch: "amd64", family: "unix"

 echo $JAVA_HOME

/usr/lib/jvm/java-1.8.0-openjdk.x86_64 Can anyone help point out what is wrong here?

Upvotes: 0

Views: 2223

Answers (3)

Sérgio
Sérgio

Reputation: 7259

completing the first answer

I got same problem after read https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html

in pom.xml we need to set source and target of maven-compiler-plugin or the default is too low

    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.12.1</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
    </plugins>

Upvotes: 0

Mark Bramnik
Mark Bramnik

Reputation: 42521

It's hard to tell without seeing an actual pom, but probably you should configure Maven compiler plugin to work with Java 8.

You can see an example of doing this here here.

The easiest way probably would be:

<project>
 [...]
  <properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
  </properties>
 [...]
</project>

Upvotes: 1

Anshul Sharma
Anshul Sharma

Reputation: 3512

i think maven project run on lower version of jdk 8. please check the version, go to project properties>Project Facets> java 1.8 version is select or not... if not then select and apply and run again.

Upvotes: 0

Related Questions