Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use Java 8 syntax in Java EE 7 projects?

Sorry for this stupid beginner's question but I wasn't able to get a clear answer for that:

Can I use lambdas, method pointers, streams etc. in a Java EE 7 project? Does this have any negative consequences or is this very difficult/error-prone to setup on a existing project?

I come from a C# background so I find it very hard to get back to Java 7 syntax with anonymous classes for runnables/callables and no replacement for LINQ like streaming etc. so this would be a huge help.

Many thanks, spyro

like image 570
spyro Avatar asked Oct 11 '16 13:10

spyro


People also ask

Is Java EE included in JDK?

No, it does not. Java EE is a specification - and its implementation can be downloaded in form of an application server (e.g. GlassFish).

Does anyone use Java EE?

Upon asking about the Java EE version, almost 40% of developers use the latest version of Java EE, although Java EE 7 still has a considerable user base and 2% of Java developers still use J2EE. The important thing to mention is that 21% of the respondents were not aware of the exact version of Java EE they are using.

What is the current version of Java EE?

Java EE 8—formally, Java Platform Enterprise Edition version 8—is now available. The release represents the first phase in Oracle's two-phase plan to embrace modern computing paradigms, particularly cloud deployments, in enterprise Java.

Which of the following APIs is part of the Java EE 7 specification?

The Java EE 7 platform requires Java Persistence API 2.1.


1 Answers

From a Java EE point of view, the Java EE 7 specification requires at least Java SE 7. So clearly, nothing prevents you from using Java SE 8 with Java EE 7. For more details, have a look here.

Some popular Java EE 7 containers like GlassFish, WildFly and Apache TomEE are Java SE 8 compatible. So there's nothing that prevents you from using Java SE 8 features in Java EE 7 applications.

like image 99
cassiomolin Avatar answered Dec 08 '22 08:12

cassiomolin