Configure Eclipse to compile with javac instead of ECJ?

I came across some java8 related code in a maven project that compiles with the javac compiler but gives compilation errors in Eclipse (ECJ compiler is different from javac I suppose).

I import it into Eclipse-Luna with: Import => Maven => Existinging Maven Project

How can I quickly fix if there is a way to get Eclipse to use javac in a maven project (thus disabling the ECJ compiler)?

EDIT : Adding a minimal poc compiler-diff example.

This code compiles with javac , but initializing List gives an error in Eclipse: "The target type of this expression must be a functional interface"

package test;

import static java.util.Arrays.asList;

import java.util.List;

public class Test01 {

    private static final List<MyInterface> items = asList(() -> "123", () -> "456");

    public void test01() {
        System.out.println("Hello");
    }

    public interface MyInterface {
        String value();
    }
}

      

The error goes away if you add typecasts:

private static final List<MyInterface> items = asList((MyInterface) () -> "123", (MyInterface) () -> "456");

      

+3
java eclipse java-8 javac eclipse-jdt


source to share


No one has answered this question yet

See similar questions:

4
How to start Javac from Eclipse

or similar:

1858
"Debug certificate expired" error in Android Eclipse plugins
1248
How can you speed up Eclipse?
1158
"Override superclass method" Errors after importing project into Eclipse
935
Eclipse Cannot Start - Java was started but exit code returned = 13
880
How do I change Eclipse to use spaces instead of tabs?
704
How do I show line numbers in Eclipse?
174
What is the difference between javac and the Eclipse compiler?
fourteen
Java generics compiles in Eclipse but not javac
8
Eclipse compiler job entirely from _within_ build.xml
6
Differences in JDK8 javac / Eclipse Luna output type?



All Articles
Loading...
X
Show
Funny
Dev
Pics