Getting started with Java EE 7 – Hands on in 10 minutes

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:

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.