NetBeans 4.1

There’s a war raging between Java integrated development environments and there’s no shortage of combatants. But NetBeans 4.1 has some not-so-secret weapons, and its arsenal of features grows by the day. Here’s a hands-on review.

There is a war raging between Java integrated development environments (IDEs) and the combat is fierce, fast, and furious.

In one theater of battle, open source tools such as Eclipse.org’s (nee IBM’s) Eclipse and NetBeans.org’s (originally Sun’s) NetBeans are aligned, skirmishing against proprietary products, including Borland’s JBuilder, MindBrain’s IntelliJ, and Oracle’s JDeveloper. Both sides are on the offensive. The open source IDEs have started to deliver visual drag-and-drop screen creation, remote and local debugging, and built-in refactoring aids that resemble some the best features provided by proprietary tools. On the other side of the combat line, the proprietary vendors are now delivering even more features, such as profiling, UML system modeling tools, and ever more clever J2EE automatic code generation wizards, among other innovations.

On another front, the two open source IDEs are skirmishing with one another: Eclipse and NetBeans continue to push one another back and forth across No Man’s Land with a seemingly unending stream of releases. In the past six months alone, I’ve reviewed NetBeans 3.6, NetBeans 4.0, Java Studio Creator (based on NetBeans 4.0 and incorporating a Java Server Faces forms designer and more), and now NetBeans 4.1. Eclipse continues to gather allies, with heavy hitters like BEA, Borland, and Macromedia providing plug-ins (Beehive, Peloton, and Zorn, respectively) that expand Eclipse’s arsenal. But NetBeans isn’t surrendering: nearly 100 NetBeans plug-ins are now available, covering everything from AspectJ integration to Java 2 Mobile Edition (J2ME) development.

But the NetBeans 4.1 graphical user interface (GUI) designer gives NetBeans an edge over Eclipse. While you can get Eclipse plug-ins for visual design, NetBeans 4.1 raises the stakes again with Matisse, which makes layout, spacing, and alignment of form components intuitive and natural. (NetBeans’s designer creates applets and application interfaces, not web application interfaces. However, if you’re using Struts, see James Holmes’s Struts Console plug-in at http://www.jamesholmes.com/struts/; if you’re using Java Server Faces, try Sun’s very adept Java Studio Creator, a bargain at $99 and based on NetBeans 4.0.) Moreover, Linux developers working on J2ME mobile applications must try NetBeans’s Mobility Pack and the J2MEWTK 1.0.4 plug-in (both from Sun).

For direct-in-the-IDE support of easy visual development, NetBeans is starting to eclipse (pardon the pun) many open source and proprietary Java IDEs.

The NetBeans Visual Advantage

As a developer, I like the organization of NetBeans’s panels. (See Figure One.)

The “Project” panel displays a tree of all the files and resources associated with a program, while the “Navigator” panel supplies a tree view of all the Java classes and imports used in a program. The “Files” and “Favorites” panels provide useful schematics of the exact file layout for a project and a way to refer to folders outside the project. In the “Design” window, the new Matisse features are very useful for GUI layout, but require a substantial learning curve.

I found “Favorites” a little clumsy — I’d prefer a full file explorer — but NetBeans makes up for this shortcoming with its “Property” panel. The “Property” panel is very helpful: just about every object in every panel has a series of properties that can be viewed and, in quite a few instances, changed.

FIGURE ONE: The NetBeans 4.1 user interface is divided into many helpful panels

The “Runtime” panel manages your open projects — yes, you can have more than one project open at any time, making it easy to borrow code or run unit tests. The same panel also manages all servers and services. Just go to the “Runtime” panel to manage application servers, start and stop the built-in HTTP server, control processes, manage code in a version control system, administer web services and XML catalogs, and, most important to me, manage databases through NetBeans’ Database Explorer (see Figure Two).

FIGURE TWO: Connecting to any JDBC- compliant database is a snap in NetBeans

To use Database Explorer, you have to add a database driver and connections to specific database instances (but two Pointbase connections are installed as defaults), but then you can right-click on a connection, connect to the database, and browse all of the database tables, views, and indexes in a tree view. As you can see in Figure Two, Database Explorer can connect to any JDBC- compliant data source.

Figure Two also shows how other panels are docked on the left side of the NetBeans IDE. These panels can be immediately activated by hovering over the panel name or clicking on it. The panels can also be dragged and dropped anywhere on the screen. NetBeans saves the state of the panels between sessions, but NetBeans doesn’t have Eclipse’s perspectives, a very smart Eclipse featue that saves different user interface layouts, say, one for design, another for editing, and yet another for debugging.

NetBeans J2EE Development

In addition to its other helpful tools and plug-ins, NetBeans 4.1 also supports a wide variety of Java 2 Enterprise Edition (j2EE) development, from servlets to Java Server Pages (JSPs) to Enterprise Java Bean (EJB) development. NetBeans has three “Quickstart” guides for J2EE applications, plus a comprehensive and very helpful tutorial on full enterprise J2EE development.

To put NetBeans 4.1 through its paces, I chose to create a simple JSP project to display the stats of the top ten baseball pitchers since 1990 based on the number of innings pitched.

Clicking on “File, New Project” opens the Project Wizard, which has “General,” “Web,” and “Enterprise” application templates. I chose “Web” and NetBeans automatically generated all of the associated directories and files, and even a deployment Ant script that’s automatically updated as new components are added to the project. Oddly though, NetBeans did not add the JSTL core libraries nor the MySQL JDBC .jar file to the project. However, it only took a few right-clicks on the “Libraries” item in the “Project Panel” to add the library and .jar s.

FIGURE THREE: Coding a Java Server Page in NetBeans

As you can see from Figure Three, creating the JSP to display the database data isn’t complex and is considerably aided by having the Database Explorer available.

First, I developed the SQL query in Database Explorer and then used cut-and-paste to place it into the appropriate JSTL code snippet. Next, I filled in the database row names with no errors (a constant source of bugs for this case-insensitive guy) using core and SQL JSTL. (Linux PHP users will feel right at home here, as both JSP and PHP follow the same templating rules.) Finally, the rebuild cycle to get the formatting right was astonishingly fast regardless of whether I used the Tomcat 5.5 or Sun Application Server 8.1. One major complaint: adding other application servers (such as IBM’s Websphere or BEA’s Weblogic) to NetBeans is very tricky.

FIGURE FOUR: A sample application quickly built in NetBeans

The final application is shown in Figure Four.

Bottom Line: Must Buy

These days, working in Java requires ramping up fast in a great number of specialized environs. NetBeans really helps in with desktop applications, J2ME mobile apps, web applications, and now enterprise applications with web services. Having a Project Wizard that reads source files and Ant scripts certainly helps, and the organization and layout of the panels with their links to the “Properties” panel for any attribute changes is clever. But most important, I find that working in NetBeans is fast and the Ant rebuilds are both smart and quick. With such great support for databases, it’s unfortunate that it only supports two application servers, Tomcat and Sun’s own. Such a pity.

So, using NetBeans is a lot like my graphics work: I use Corel/Jasc PaintShop Pro for speed and versatility and then switch to Adobe’s Photoshop for specialized tasks. For Java, I use NetBeans and then Borland JBuilder (or my client’s Java IDE of choice).

If you’re a Java newbie, reading Ivor Horton’s Beginning Java 2 or Sierra’s and Bates’s Head First EJB, say, keep NetBeans at the ready to do exercises. NetBeans will shift your learning into high gear.

Jacques Surveyer is a writer and consultant. His web site can be found at http://www.theopensourcery.com.

Comments are closed.