Java 8 support?

When Java 8 is shipped in March (according to schedule) can I use it for developing Vaadin applications?

Especially I am interested in using the lambda support for getting terse code.

Thanks,

Anders

Yes, you might want to take a look at
this blog post
:slight_smile:

Anyone got Java 8 to work with Vaadin in Eclipse yet?

I tried Kepler SR2 with Java 8 patch, installed and configured Eclipse to use the released JDK 8.
In Eclipse prefs I switched to JDK 8 and source code compliance to Java 8.

I got the missing facet error in Eclipse "
Java compiler level does not match the version of the installed Java project facet"
, but Henri Muurima said it could be ignored.

When trying to run Tomcat (7.0.35) I got an error that it couldn’t be started and in the console window I saw the below stack trace:

[size=3]
java.lang.NoSuchMethodError: sun.security.ec.NamedCurve.(Ljava/lang/String;Ljava/lang/String;Ljava/security/spec/EllipticCurve;Ljava/security/spec/ECPoint;Ljava/math/BigInteger;I)V

at sun.security.ec.CurveDB.add(CurveDB.java:147)

at sun.security.ec.CurveDB.<clinit>(CurveDB.java:171)

at sun.security.ec.SunECEntries.putEntries(SunECEntries.java:72)

at sun.security.ec.SunEC.<init>(SunEC.java:76)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(Constructor.java:408)

at java.lang.Class.newInstance(Class.java:433)

at sun.security.jca.ProviderConfig$2.run(ProviderConfig.java:221)

at sun.security.jca.ProviderConfig$2.run(ProviderConfig.java:206)

at java.security.AccessController.doPrivileged(Native Method)

at sun.security.jca.ProviderConfig.doLoadProvider(ProviderConfig.java:206)

at sun.security.jca.ProviderConfig.getProvider(ProviderConfig.java:187)

at sun.security.jca.ProviderList.loadAll(ProviderList.java:282)

at sun.security.jca.ProviderList.removeInvalid(ProviderList.java:299)

at sun.security.jca.Providers.getFullProviderList(Providers.java:173)

at java.security.Security.getProviders(Security.java:452)

at org.apache.catalina.core.JreMemoryLeakPreventionListener.lifecycleEvent(JreMemoryLeakPreventionListener.java:382)

at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)

at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)

at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:402)

at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:99)

at org.apache.catalina.startup.Catalina.load(Catalina.java:633)

at org.apache.catalina.startup.Catalina.load(Catalina.java:658)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:483)

at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:281)

at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:455)

[/size]

I think you need WTP support for Java 8 in Eclipse to make this easy: https://bugs.eclipse.org/bugs/show_bug.cgi?id=426884. Apparently this was fixed last week and is available in some snapshot build already and should be in the next milestone release, “M7 is scheduled for 2014-05-07”.

Otherwise you need to ensure that you do not have a mismatch between JDK versions used to compile the project and the JDK version used to run Tomcat (just guessing here)

If you are not tied to Eclipse, NetBeans has an amazing, stable, built-in Java 8 support.
Join our webinar
on thursday to see how it performs.

cheers,
matti

I can’t switch from Eclipse, and since it is my favourite editor I wouldn’t like to either :wink:

I tried the I-build which should have the facet, but I ran in to other problems.
One being weird errors in Eclipse that I needed to implement interface methods, even though they were so called “default” methods.

It seems I need to wait for at least M7 for things to stabilize (which is a petty because the lambdas really make the code much nicer).

Hi!

I’m using Eclipse Luna EE M6 with (some) updates from latest I-build, and it’s working quite well
in combination with JDK8u20, Tomcat 8.0.5 and Vaadin 7.1.13 (since right now).
As you quoted Henri, there is an error message about the non-matching Java facet, but that’s not
a problem.

Me too had to implement a ‘forEach’ and a ‘spliterator’ method for an extended vaadin UI,
but now i deleted my overwrites, an everything is fine now. Maybe some caching or project cleanup issues…

It’s a shame, that the next milestone is more than a month away, that could have made life
a lot easier, i’m thinking about giving netbeans a new change.

greetings
Ralf

Update:

Here:
http://stackoverflow.com/questions/21955207/version-1-8-of-project-facet-java-does-not-exist
is the link to a reported bug and a link to a patch.
I just installed it, and it seems to work!

greetings
Ralf

Thanks Ralf, I got it to work with Kepler SR2 + Java8 update patch + Java 8 facet patch.

Regards,

Anders

BTW, I love the CTRL+1->“Convert to lambda expression” in Eclipse:

-                UI.getCurrent().access(new Runnable() {
-                    @Override
-                    public void run() {
-                        progress.setValue(0.5f);
-                    }
-                });
+                UI.getCurrent().access(() -> progress.setValue(0.5f));

Old trick for NetBeans users :slight_smile: NetBeans can also suggest to use method references in applicaple places. I’d guess Eclipse will support that at some point too.

Althought IDE’s did pretty good job with inline classes as well, lambdas really made old inline listeners look funny.

cheers,
matti