Last week saw the release of Java EE 7 – the new edition of the Java Enterprise platform. It is a substantial release – which advances the Java Enterprise Platform in many areas. What this release consists of really is the following
- the common understanding between major stakeholders in the Java community – laid down in formal specifications – about how the Java platform will support many aspects of implementing enterprise applications, including (fairly) recent developments such as RESTful services, JSON format, WebSockets communication, HTML 5 rendering, parallel batch processing.
- an example implementation of a Java EE container that will run Java EE applications that are built according to said specifications; this is GlassFish 4.0 Application Server.
- an important incentive to Java vendors to upgrade their Java EE containers (JBoss, Tomcat, IBM, Oracle, …) and a similar impetus for Java developers to upgrade their skill set and start leveraging new standards and facilities (although at this point most of us are still absorbing many of the Java EE 6 improvements)
- a fresh wave of energy, focus, enthusiasm, hope and expectation through the Java community; Java is alive and revitalized
- many new resources that explain the Java EE 7 release and the new aspects of the upgraded specifications including code samples and use cases
Getting started
To get started on a theoretical level is really easy. Great resources have been published in abundance. Some suggestions:
- Overview presentation of Java EE 7 (one hour webcast) : https://blogs.oracle.com/java/entry/a_java_ee_7_sneak and the associated slide deck: https://glassfish.java.net/javaee7/techkit/JavaEE7-1hour.pdf
- Presentations on Java EE 7 (webcast): http://www.youtube.com/GlassFishVideos
- Overview of Java EE 7 resources: https://blogs.oracle.com/theaquarium/
- The Java EE 7 Tutorial (the former Sun Java EE tutorial, upgraded to Java EE 7): http://docs.oracle.com/javaee/7/tutorial/doc/home.htm
- Replay from the June 12th Java EE 7 Launch Event: http://vshow.on24.com/vshow/oraclejava#exhibits/java with video overviews of the 16 new JSRs, strategy and technical keynote presentations moderated by Arun Gupta, Java EE and GlassFish Guy, Oracle
To start actually doing things – there is no easier way than the following, allowing you to have your first Java EE 7 artefact running in about 10 minutes (depending mainly on your network bandwith):
- Download NetBeans 7.3.1 from https://netbeans.org/downloads/ – choose the Java EE edition, which comes bundled with GlassFish 4.0 as embedded container (201 Mb)
- Install NetBeans – just run the install wizard
- Start NetBeans and create a Java EE 7 component using the samples available from the New [wizard]
- Run the sample – after perhaps making some changes of your own – from within NetBeans on the embedded GlassFish 4.0 server
Let’s go ahead and do it. I will assume that you have download NetBeans and installed & started it.
After NetBeans has launched, create a new project:
Click on File | New Project. In the dialog you can select a template for the new project – as well as start from a shipped Java EE 7 sample:
In this case I have selected Expression Language as my sample; other options include JAX-RS, Servlet, CDI, EJB, Java Batch and other Java EE specifications.
Press Next. Specify the location for the project, and press Finish:
The project is created and the initial setup is applied. In this case, the Class Main contains the Java EE 7 specific content:
Notice how EL 3.0 supports method calls, multiple statements, different collection operations and also the concept of lambda expressions (‘functions as parameter’s’) that can be used for example to specify how filter conditions should be applied to collections.
You can run this class from the context menu (or using Shift+F6):
and see the results:
I think if you have watched the clock closely you are still under 10 minutes…
Now of course the real fun should start: take the sample as your starting point and then start trying out your own variations.
Resources
Also see https://blogs.oracle.com/theaquarium/entry/el_3_0_public_review about the EL 3.0 specification