NetBeans is Oracle’s (formerly Sun Microsystems’s) open source pure Java integrated design environment (IDE). Since starting to program in Java I’ve tried a few free IDEs, Eclipse, JEdit and IntelliJ IDEA Community, but I believe non are currently as intuitive, feature rich, reliable and well integrated with Java EE technologies as NetBeans.
In the past NetBeans has been considered to be slow and less feature rich when compared to Eclipse – these things are simply no longer true. Eclipse may still have a sight performance edge over NetBeans because of its native code components, but not enough to be bothered by, and more importantly everything you can do in Eclipse, you can do in NetBeans and loads more!
NetBeans is not only a great IDE for Java development, but also supports other languages. NetBeans is also my preferred IDE for C and Python development.
JavaEE 6 (JEE 6) is the latest Java Enterprise specification, consisting of EJB 3.1, JPA 2.0, JSF 2.0, Servlet 3.0 and other updates to the JavaEE stack. New additions include JAX-RS for RESTful web service development and CDI for dependency injection.
The JavaEE 6 standard is my technology of choice for new projects, vastly superior to the older EJB 2.0 technology, a productivity step up from JavaEE 5 / EJB 3.0, and in my opinion more reliable and simpler to maintain than Spring/Hibernate technologies.
Packt Publishing requested that I review one of their new titles about NetBeans and JavaEE: JavaEE 6 Development with NetBeans 7 by David R. Heffelfinger, available to buy from Packt’s website.
JavaEE 6 Development with NetBeans 7 is a very good book which complements a very good IDE. It has improved my usage of NetBeans and has brought me up to speed with the latest additions to the Java EE specification. I’m looking forward to the next project which will let me put into practice the new things I’ve learnt from this book. JavaEE 6 Development with NetBeans 7 covers the full JEE 6 stack, from first principals, with examples deployed on GlassFish application server.
The book focuses on the full JEE 6 technology range, including some elements which aren’t used much anymore in production deployments (JSP SQL tags), but are there for the sake of thoroughness. Each part of the JEE stack has a chapter which is a great introduction to that topic, and will get you up and running with a usable example in no time at all.
No part of the stack is covered in great depth, but you wouldn’t expect that from book only 360ish pages long. Each chapter provides a solid foundation for you get grips with the basics, and up and running with a working example, so you can feel confident in exploring further using other books or online sources if you wanted.
The book will appeal to a range of developers. If you are familiar with Java and wanted to learn JavaEE 6 development, this book would give a great start. If you are already a JEE developer and wanted to brush up on the new additions to the JEE standards than this book is a worthwhile read. Or if you’re a developer, convinced that Eclipse, Spring, Hibernate and JBoss are the pinnacle of Enterprise Java development, then please give this book a try, it could be an eye opener.
The first chapter starts out by introducing the reader to NetBeans and it’s JEE capabilities. You are shown where to download the IDE from, what bundle to choose from, and how to install it on your development platform; with information for Windows, Linux and Mac OS X. The chapter guides you through the installation procedure with excellent step by step screen shots (which are provided for every step in every example throughout the book), and how to start the IDE for the first time.
The book then goes through the steps to integrate NetBeans with other applications servers and databases in case you want to use JBoss or MySQL, but I decided to stick with GlassFish and Derby that come installed by default. To make sure everything is working, the books show you how to create a sample application, deploy to GlassFish and test it in your browser. Only a few pages into the book and you’re up and running with a JavaEE web app – good stuff.
The remainder of the chapter details the developer productivity features that NetBeans provides, such as code completion, code templates, keyboard shortcuts and the editors visual queues; helpful stuff for knocking out the code faster and with fewer errors.
Chapter two covers how to create and deploy a simple JSP and Servlet application. The reader is guided thought how to modify the default new project code and how to create new HTML by dragging and dropping from NetBeans HTML palette. The Model-View-Controller design pattern is introduced and implemented, and authentication and authorisation are added to the application using GlassFish security realms, with form based authentication using a file realm. Finally the code is made more maintainable by using JSP fragments to reduce code duplication.
At only 100 pages into the book you have rapidly created a maintainable, secure and well architected web application!
Building on the previous chapter, chapter three introduces using JSP tags for conditional logic. SQL tags are introduced for querying and modifying data from a database, and the reader is rightly advised that a more robust method should be used for accessing the database in production systems. Custom tags are then used to encapsulate HTML mark-up and JSP functionality.
Chapter four introduces JavaServer Faces and chapter five builds on it with PrimeFaces. I’ve not used JSF since version 1.2 and was not familiar with PrimeFaces, so I was very impressed with the visual results achieved by the end of the two chapters. PrimeFaces and its AJAX capabilities are definitely something I want to explore further.
Chapter six contains some great information; it begins with how to access the database using the Java Persistence API, covering Entity Beans and how to annotate them. The Data Access Object pattern in demonstrated with JPA Controllers for encapsulating data access functionality. Now this is where NetBeans really starts to shine with respect to its code generation capabilities. The last half of the chapter shows how to generate Entities and Controllers from the database without having to manually write a line of code. Finally a whole JSF application for viewing and modifying the database data is generated from the Entity Beans. By the end of this chapter you can create a complete end-to-end data driven web application without writing a line of code. If you’re a developer who is already familiar with the JPA, its worth giving this chapter a read for the new features introduced as part of JPA 2.0, such as the new JSR 303 Bean Validation annotations.
Chapter 7 covers how you will implement your business rules and domain logic in an EJB environment using session beans. The chapter guides us through creating remote stateless session beans and how their functionality can be access across the network from a client. Aspect Oriented Programming using Interceptors is introduced as well as the EJB Timer service for scheduling tasks. Again NetBeans code generation capabilities are used to automatically create session beans from our JPA entities, saving development time.
The new API introduced in Java 6 for dependency injection CDI (Contexts and Dependency Injection), is covered in chapter 8. This great new feature should simplify integrating different application layers, and improve the maintainability of your code. CDI scopes and the @Inject and @Named annotations are used in the examples along with Stereotypes to group together CDI code.
Messaging with JMS and message driven beans is covered in chapter nine. The chapter introduces Queues and Topics, message producers and consumers, and demonstrates how to implement a message Queue and receiver bean. NetBeans can generate the all boilerplate code required to use Message Driven Beans, taking the work out of creating loosely coupled architectures.
The final two chapters detail the usage of Web Services. Chapter ten covers how to create SOAP Web Services with JAX-WS, and chapter eleven RESTful Web Services with JAX-RS. The advantages of using web services as they are client platform agnostic are discussed before creating a web service by using the @WebService and @WebMethod annotations.
NetBeans graphical Web Service design interface is used to create a web service without having to manually write a WSDL file, and then tested with NetBeans web service testing features to view the XML messages sent backwards and forwards.
The rest of chapter ten shows us how to simple crate a SOAP client my dragging and dropping the Web Service methods on to a class, how to generate code to create a web service from an existing Session Bean and how to generate a web service from an existing WSDL.
The last chapter shows us how to generate the code to REST enable a database and create a client with just a few clicks.
Overall I think this is a great book. It contains the things that make me enthusiastic about Enterprise Java Development: EJB 3.1, JPA 2.0 and GlassFish. The book is well written and well structured; it flows from one chapter to the next, building on what you have learned before. The text is accurate and concise, and the screen shots throughout the book are so useful that you could follow most of the examples from them alone.
Most importantly, the code printed in the book is correct and easy to follow, I found no syntax errors in it.
The book should appeal to novice Enterprise Java developers as well as experienced programmers who want to brush up on the latest standards or need a firm foundation in an area of JEE they haven’t covered before.
I’m looking forward to using some of the new things I’ve learned from the book in new projects. I hope the author continues to update the book in subsequent editions as and when the JEE standards evolve.
Downloads From Packt
- Sample Chapter - 2701OS-Chapter-4-Developing-Web- Applications-using-JavaServer-Faces-2.0.pdf
- Example Code - 2701OS_Code.zip