Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"java: Duplicate methods named XXX" issue when using Eclipse compiler in IDEA with JDK 8

With the following simple class I get java: Duplicate methods named spliterator with the parameters () and () are inherited from the types java.util.List<T> and java.lang.Iterable<T> error if using Eclipse compiler in IDEA with JDK 8:

public class Java8Test {
    public static interface Traverable<T> extends Iterable<T> {}
    public static interface List<T> extends Traverable<T>, java.util.List<T> {}
}

If change the compiler to javac, then there is no error. The error also gone if switched to JDK 6 with eclipse compiler.

IDEA version: 12.1.5

like image 625
Gelin Luo Avatar asked Oct 02 '13 12:10

Gelin Luo


1 Answers

I got the same error when trying to compile Java 7 code with a Java 8 JDK.

The solution that worked for me was changing the JRE configured in Eclipse to a Java 7 one: Window -> Preferences -> Java -> Installed JREs. Edit the existing one and select a directory containing a Java 7 JDK.

like image 191
Fabian Streitel Avatar answered Oct 22 '22 01:10

Fabian Streitel