eclipse - Lambda Expressions java 8 exception : java.lang.NoSuchMethodError: java.lang.invoke.LambdaMetafactory.metaFactory -


i have problem running following code:

    public class lambdatesting {         public static void main(string[] args){              new lambdatesting();             }         public lambdatesting(){             test1();         }         private void test1(){             runnable x = () -> system.out.println("ok"); //error         }     } 

which causing following exception:

*exception in thread "main" java.lang.incompatibleclasschangeerror  @ java.lang.invoke.methodhandlenatives.linkmethodhandleconstant(methodhandlenatives.java:383)     @ lambdatesting.test1(lambdatesting.java:24)     @ lambdatesting.<init>(lambdatesting.java:20)     @ lambdatesting.main(lambdatesting.java:15) caused by: java.lang.nosuchmethodexception: no such method: java.lang.invoke.lambdametafactory.metafactory(lookup,string,methodtype,methodhandle,methodhandle,methodtype)callsite/invokestatic     @ java.lang.invoke.membername.makeaccessexception(membername.java:765)     @ java.lang.invoke.membername$factory.resolveorfail(membername.java:882)     @ java.lang.invoke.methodhandles$lookup.resolveorfail(methodhandles.java:1019)     @ java.lang.invoke.methodhandles$lookup.linkmethodhandleconstant(methodhandles.java:1284)     @ java.lang.invoke.methodhandlenatives.linkmethodhandleconstant(methodhandlenatives.java:381)     ... 3 more caused by: java.lang.nosuchmethoderror: java.lang.invoke.lambdametafactory.metafactory(ljava/lang/invoke/methodhandles$lookup;ljava/lang/string;ljava/lang/invoke/methodtype;ljava/lang/invoke/methodhandle;ljava/lang/invoke/methodhandle;ljava/lang/invoke/methodtype;)ljava/lang/invoke/callsite;     @ java.lang.invoke.methodhandlenatives.resolve(native method)     @ java.lang.invoke.membername$factory.resolve(membername.java:854)     @ java.lang.invoke.membername$factory.resolveorfail(membername.java:879)     ... 6 more* 

i have installed jdk8 downloaded from: http://jdk8.java.net/lambda/ (windows x64 version)

i run in eclipse version: 4.4.0 downloaded from: http://downloads.efxclipse.org/eclipse-java8/2013-06-30/ (file: org.eclipse.sdk.ide-win32.win32.x86_64.zip 30-jun-2013 17:35 180m)

eclipse.ini file:

-vm c:\program files\java\jre8\bin\java.exe -startup plugins/org.eclipse.equinox.launcher_1.3.0.v20130327-1440.jar --launcher.library plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20130521-0416 -showsplash org.eclipse.platform --launcher.defaultaction openfile --launcher.appendvmargs -vmargs -xms40m -xmx512m 

project properties -> java compiler -> compiler compliance level: 1.8 (beta) (use default compliance settings checked).

project properties -> java build path -> libraries: jre system library [jre8]

project run configurations:

[jre tab] project jre (jre8) checked

[classpath tab] boostrap entries: jre system library [jre8]

i have tried run lambdatesting.class command line inside jre8/bin directory same exception appeared.

java version:

c:\program files\java\jre8\bin>java.exe -version java version "1.8.0-ea" java(tm) se runtime environment (build 1.8.0-ea-b102) 

my operating system is: windows 7 x64

any clues ?

thanks @assylias solved problem of compilation command line using jdk1.8.0/bin/javac.exe, still no result in eclipse. seems eclipse has wrong compiler. tried change settings in: preferences -> java -> compiler, can choose version 1.7 in "generated .class files compatibility" (no 1.8 available in setting). "use default compliance settings" causing above mentioned exception.

i found example compiles fine latest beta. not sure trying evaluate did similar test follows:

public class lambdatesting {     public static string[] strs = { "a", "aa", "aaa"};      public static void main(string args[]) throws exception {         executorservice pool = executors.newfixedthreadpool(3);         set<future<integer>> set = new hashset<future<integer>>();         (string word : strs) {              callable<integer> c = (() -> word.length());              future<integer> future = pool.submit(c);             set.add(future);         }         int sum = 0;         (future<integer> future : set) {             sum += future.get();         }         system.out.printf("the sum of lengths %s%n", sum);         system.exit(sum);     } } 

i used example executor found here: java runnable run() method returning value base program , substituted lambda expression wordcount. worked fine latest java 8 beta , september 2013 build of eclipse kepler found here: http://downloads.efxclipse.org/eclipse-java8/ - trip


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -