Java EE 6 in NetBeans IDE 6.8 Milestone 1
You may know that the next iteration of the Java Enterprise Edition, i.e. Java EE 6, is nearing completion. Many key specifications, including Java Persistence 2.0, JavaServer Faces 2.0 and EJB 3.1 are now in the Proposed Final Draft phase. In version 6.8 Milestone 1, NetBeans is now adding support for the Java EE 6 platform.
This entry is not meant to be a general introduction to Java EE 6—for a basic overview, see e.g. this introductory article by Reza Rahman. Rather, we will focus directly on the EE 6 support in NetBeans area by area.
Creating Java EE 6 applications
The first change you will notice is that NetBeans now uses GlassFish v3 promoted builds as the built-in server, which supports EE 6 out of the box. Accordingly, when creating one of the Java EE projects (Web, EJB, AppClient or EAR project), 'Java EE 6' is now available as a choice in the New Project wizard.
This is the only time you are required to specify a Java EE version: after that, NetBeans automatically figures out what versions of the sub-specifications to use based on what your server supports, what is your Java EE version etc. This has a nice side effect—if you use a server that only supports Java EE 5, such as GlassFish v2.1, you can still use some of the Java EE 6 technologies. For example, JSF 2.0 can be used with Java EE 5 projects, as well as JAX-RS (Java API for RESTful Web Services) 1.0, and NetBeans enables you to do just that.
JavaServer Faces 2.0
The big changes in the JSF area include the usage of Facelets as the default page language, and usage of annotations instead of XML configuration. Facelets was a successful technology even before JSF 2.0, and for a long time NetBeans has provided support for pre-EE 6 Facelets through the nbfacelets module. In NetBeans 6.8 M1, this module is included directly, so facelets format is supported out of the box, as you can see in the screenshot below.
Java Persistence 2.0
NetBeans 6.8 Milestone 1 now allows you to take advantage of the new features in JPA 2.0, such as the Criteria API or integration with the Bean Validation specification. When using JPA in Java EE 6 projecs in NetBeans, these new APIs are available out of the box.
Enterprise JavaBeans 3.1
The most expected feature of EJB 3.1 is the ability to use EJBs in ordinary web modules. This is a major simplification of the build/packaging/deployment process—instead of an EAR file with two submodules (web and EJBs), many applications will now need just one WAR file. Indeed, NetBeans makes it possible to build such applications: wizards for creating EJBs are available in ordinary web projects, and you now see them in the project explorer, as shown on the screenshot below.
This picture shows one other interesting feature—the support in RESTful web services, which you can also create in web projects.
Servlet 3.0 specification defines annotations that can be used in place of XML configuration. For example, when creating a servlet in NetBeans, XML configuration in web.xml is by default not created—rather, annotations on the servlet define its deployment properties. One nice sideeffect of this is that many web applications will not need web.xml at all—one less XML file to worry about. And as you might expect, when you create a web project in NetBeans 6.8 M1, it does not have web.xml by default.
And there is much more
While JPA 2.0, JSF 2.0, EJB 3.1, Servlet 3.0 and JAX-RS 1.0 are probably the most notable and important improvements in Java EE 6 compared to the previous version of the platform, the changes that support EE 6 development in NetBeans 6.8 do not end here. Other notable differences in NetBeans 6.8 M1 include:
- NetBeans 6.8 M1 now includes the complete Javadoc for the Java EE 6 platform.
- NetBeans now bundles the new libraries from the Java EE 6 platform, including the latest builds of EclipseLink 2.0, JSF 2.0, the Metro web services stack etc.
- New versions of all the deployment descriptor are supported in the graphical and text editors
For a complete description of Java EE 6 features in NetBeans 6.8 Milestone 1, see the New and Noteworthy page.
This article is the first in a series of articles about Java EE in NetBeans—in the future, we plan to regularly publish articles about Java Web and EE development in NetBeans. Such entries will be tagged with 'JavaEE', so you can bookmark this link to get to them directly.
To find out more about Java EE 6 and NetBeans, you can also explore the following resources: