Getting started with Java EE 7 - Hands on in 10 minutes image37

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.
    image
  • 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.
    image
  • 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
    Java EE 7

Getting started

To get started on a theoretical level is really easy. Great resources have been published in abundance. Some suggestions:

 

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)
    image
  • 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:

image

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:

image

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:

image

The project is created and the initial setup is applied. In this case, the Class Main contains the Java EE 7 specific content:

image

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):

image

and see the results:

image

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

ALT_DESCR