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
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.
Also see https://blogs.oracle.com/theaquarium/entry/el_3_0_public_review about the EL 3.0 specification
- First experiences and getting started with GlassFish 3.1 and NetBeans 7.x – it's a breeze
- Java EE 6 and GlassFish 3.0 released!
- CometD 2 Java Client Sample – open project in NetBeans based on Maven pom file, modify sources and run Java Based Comet Client
- Getting started with Java Server Faces (JSF) using Apache MyFaces – in JDeveloper 10.1.3EA
- Book review of: Getting Started With Oracle SOA Suite 11g R1: A Hands-On Tutorial
- The AMIS Summary of Oracle OpenWorld 2013 is available for download – 60-page white paper
- On the integrity of data in Java applications – presentation from JFall 2013
- Book Review of Building Modular Cloud Apps with OSGi by Bert Ertman and Paul Bakker (last edit: 25th October)
- Java 8 – Collection enhancements leveraging Lambda Expressions – or: How Java emulates SQL
- OOW13: summarizing one week and 2000 sessions in 3 hours and a bit – the yearly AMIS OOW Review session – 10th October
- JavaOne 2013: (Key) Notes of a conference – State of the Java platform and all the roadmaps
- OOW13 and JavaOne 13: Notes from a Conference – Part Two
- OOW13 and JavaOne 13: Notes from a Conference – Part One
- Giving Java 8 a spin using NetBeans 7.4 RC
- JDeveloper 12c & ADF 12c: Launch of the next generation