Enterprise Application Development with NetBeans IDE


The NetBeans Integrated Development Environment (IDE) is one solution for all your Java development needs. It is ideal for Java programmers - not just a generic environment that tries to provide a little something for everyone. In this white paper we would like to share a IDE success story from Infosys (www.infosys.com), a global consulting and IT Services company, on how the NetBeans IDE helped them to turn a concept demo into a real life enterprise application.

Here is a quote from the Infosys Principal Architect, “It started with an intention to build a demo application using the NetBeans IDE for internal training in our organization. But as we added features into the application – it was remarkably easy, thanks to the new and intuitive features in both Java EE 5 and the NetBeans IDE – we only ended up being thirsty to add more and more functionality into our real application”.

The Application

Enterprise Asset Management is vast and spans inventory management, supplier management, CRM solutions, billing solutions, work flow management, resource tracking, order management, and synchronization of various artifacts across factory premises, warehouses and sales desks. The team was asked to concentrate on the very basics, which included asset management, asset tracking, order management, inventory management and a simple and tailor-made customer relationship management implementation. The figure below shows the overall system use case.

Asset Management use case

Why NetBeans IDE?

The NetBeans IDE is a robust, free, open source Java IDE that provides the developer with everything they need to create cross-platform desktop, web and mobile applications straight out of the box. It comes with the following features:

Supported Java technologies :

  • Latest Java SE, Java EE support including annotations and JPA

  • NetBeans Enterprise Pack - SOA Tools including excellent Visual editors for BPEL, XML Schema and Visual BPEL Debugger

  • NetBeans Visual Web Pack - Visual editor for JSF projects

  • NetBeans Mobile Pack - The Best Java Mobile Application editor for CLDC and CDC

  • NetBeans Profiler

  • NetBeans GUI Builder for Swing based Rich GUI applications

Other Key IDE features :

  • Best out of the box experience

  • The best Ant support for projects

  • Web wervice security

  • JUnit support

  • Supports multiple version control systems

  • Excellent forum support and lot of learning resources

  • Multi-platform support and look and feel (Windows, Linux, Solaris and MacOS)

  • Multi-language support including Java, C/C++, JavaScript and Groovy etc.

  • Support for multiple application servers and database servers

  • Auto update, easy to configure, localization, accessibility support, and many more features

Enterprise Application Development Experience:

NetBeans IDE provides excellent out-of-the-box experience from simple Java SE/EE development to enterprise application programming. The NetBeans IDE includes programmer-friendly features like annotations, code completion, refactoring, dependency injection in Java SE 5 and powerful Java Persistence API in EJB 3.0. The UML functionality in NetBeans IDE helps to reverse engineer Java code and apply design patterns to Java code.

The Enterprise Asset Management The application consists of a web interface to manage assets and purchase orders. Now we will see how this application is developed using NetBeans IDE.

Create Java Application:

In the IDE's File Menu, choose New Project. In the category “General”, select “Java Application”. Click on Next and set Project Name to “EAM-Asset”. We will add persistent classes for Asset. Similarly Create Java Project “EAM-PO.” This will be used for purchase order persistent classes.

DataBase Connection:

NetBeans IDE has an easy to use interface for databases. JavaDB is installed as a part of Sun Java System Application server or GlassFish Server installation. The following picture shows database integration in NetBeans IDE. It is easy to configure other JDBC drivers/servers.

EAM-Asset application (Persistence classes from database tables)

Create a Java Application “EAM-Asset”. Add “Entity class from database”. The Entity Class wizard connects to the Java DB server and fetches the tables list from the database. In this case, we are using “MASTERASSETTABLE” as shown below.

This wizard allows users to edit the entity class's name. For example “Masterassettable” can be changed to “Asset”.

In the same panel there is a button for creating a “Persistence Unit” which will be created and added to the Web application automatically.

Adding Annotations to Asset class

Once the “Asset” class is created, we added the following inheritance strategy and discriminator in the code.


Code Completion Support for Annotations:

NetBeans IDE provides full code completion support for annotations and attributes, which means less compilation errors and time saving. See the following picture for code completion for Java persistence annotations.

Code completion support for attributes in Annotations:

Code completion also supports attributes.

We use the “HardDrive” and “Monitor” classes by extending the Asset class. Similarly, we created the EAM-PO (Enterprise Asset Manager Purchase Order) application, using "LineItems" and "PurchaseOrder" tables as we discussed earlier.

We also added the following classes to the EAM-PO application.

  • HardDriveLineItem extends "LineItem" and implements methods.
  • MonitorLineItem extends "LineItem" and Implement methods.

NamedQueries are generated Automatically:

We added the following custom NamedQuery to the existing NamedQueries list in PurchaseOrder.java.

    @NamedQuery(name =
"PurchaseOrder.findByShipment", query = "SELECT m FROM
PurchaseOrder m WHERE m.shippingAddress = :shipment")

Web interface for asset management application.

We created a Web Application named “EAM-AsserMgmt-web” and added the following servlets:

  • AssetMaster

We added a JDBC resource and called it "jdbc/myDatasource" using existing the DataBase Connection Pool, or the user can create a new connection pool.

Adding JDBC Resource:

Verification of JDBC Resources:

Once the JDBC Pool and Resource are registered with the application server, they can be verified in the IDE's Runtime Tab.

Creating PersistenceUnit:

Adding a persistence unit was never an easy task, but with the IDE's project wizard it is simplified now.

Adding PersistenceContext to Servlet :

We selected each of the servlets and added @PersistenceContext, @Resources.

This will automatically add a “persists” method as shown below.

“AssertValidation.js” and “commonstyle.css” are added to the application.

Then we implemented the required logic in the following servlets.

  • DeleteAsset

  • EditAsset

  • ListAssets

Fix Imports Automatically

Whenever new classes are added to servlets including annotations, the IDE fixes imports automatically.

Add Try-Catch Automatically

If there are any lines of code that need to be wrapped by a try-catch-block, the NetBeans editor does this automatically.

Refactoring support in NetBeans IDE

The user can make use of various IDE's refactoring features to manage code.

For instance, finding the usage of a variable in the NetBeans editor, or finding any unused variables in the code.

Visually Editing Web.xml

The web deployment descriptor provides a visual representation of “web.xml”. It is easy to navigate between different sections of web.xml.

Setting Breakpoints in the Code

Setting breakpoints in the code and debugging the application is very simple in NetBeans IDE.

We added the following servlets to EAM-PO-web application.

  • CancelPurchaseOrderServlet
  • CheckPOStatusServlet
  • EditPurchaseOrderServlet
  • GetAssetPropertiesServlet
  • MasterPurchaseOrderServlet
  • SaveEditPurchaseOrderServlet
  • SavePurchaseOrderServlet

Then we added the JDBC resource, @PersistenceContext and @Resources in Servlets, and implemented the business logic in the servlets.

Creating UML Model from Java Classes

The NetBeans UML plugin was used to do analysis and round-trip engineering on the Java Code. NetBeans UML offers several enterprise class features.

  • Forward and reverse engineering:  You can generate Java code from your model as well as create UML models from your existing Java source.

  • Markerless code generation:  The code generated by the UML module is free of any artificial markers, e.g. comments or tags, introduced solely to support code generation.

  • Support for diagrams:

  • Activity diagram
  • Class diagram
  • Collaboration diagram
  • Component diagram
  • Deployment diagram
  • Sequence diagram
  • State diagram
  • Use Case diagram
  • Requirements gathering:  You can bring application design requirements into your model via an XML file or import them from Telelogic's DOORS requirements tool.

  • Predefined and Extensible Design Patterns: There is a full set of design patterns including EJB 1.1, EJB 2.0 and Gang of Four (23 patterns).

  • Rational Rose Import: You can import models created by Rational Rose into your project allowing easy migration of existing projects.

  • Web Reporting:

Executing the application

After we cleaned, built and deployed both the web applications, we selected each webapplication and ran it from the IDE. The welcome page of each webapplication is launched in the webbrowser.

PurchaseOrder servlet

Create Purchase Order. (Click to zoom)

Purchase Order Details (Click to zoom)

Verify Purchase Order in Database (Click to zoom)

Purchase Order Summary (Click to zoom)

Executing “Assetmanagement” Servlet.

Adding a harddisk to asset list. Similarly add a Monitor.

Verify hard drive and monitor records are added in database. (Click to zoom)

Editing asset.

Asset List


Developing enterprise scale applications was never so simple, definitely. NetBeans IDE and the NetBeans Packs empower enterprise application developers to reduce the complexity and increase productivity. Several scripting modules are being added to NetBeans IDE which enables it to serve broader development needs. NetBeans IDE makes enterprise development much simpler and much less boilerplate.

Resources for further reading

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2016, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo