In association with heise online

26 June 2008, 13:02

NetBeans 6.1 Reviewed

DJ Walker-Morgan

NetBeans 6.1 has arrived and although it's a point release, that hasn't stopped the NetBeans developers putting in lots of new features.

Top of the list for your modern web developer will be the new JavaScript editor. Now, "editor support" doesn't sound that exciting – colour the syntax a bit, throw in some editor short cuts and command complete the keywords – and this was the state of play for NetBeans 6.0. In NetBeans 6.1, the support goes much deeper, using a type inference mechanism to make code completion make sense. The problem with code completion for JavaScript is that it is a dynamically typed language. In Java, for example, a variable would have a declaration in the code saying what type it was, in JavaScript, there is no declaration of type, so given a variable "foo", the editor would have no idea if it was a string, a number or some other object. NetBeans 6.1 now analyses the surrounding code, so say in a simple case, you have

foo="something" bar=foo.

and you invoke code completion after the ".", the Integrated Development Environment (IDE) looks at its code analysis, and sees that foo was previously assigned with a string, so there's a high probability that it is still a string. The code completion then offers the string methods first, then the other methods that could apply.

The code analysis also covers surrounding HTML code, which NetBeans already syntax colours and completes, but the benefits of this only become apparent when you find NetBeans knows, not just about core JavaScript, but also about common libraries like Prototype and JQuery. When you start entering say JQuery's selector, $("") and call up code completion within the quotes, it offers you the HTML elements in the surrounding page as possible completions.

The code analysis also includes any other included Javascript libraries, presenting you with any documentation that exists in the library; comments are parsed by the code analysis, letting the IDE flag up whenever a comment for a function doesn't match the actual function definition. Not quite as neat as the Java editor, which generates comment block content when you enter a /** before a method, but then the Java editor doesn't flag comment errors in the same way. Overall, the JavaScript editor is a great enhancement to NetBeans.

Web Service Clients

Writing a client that queried a web service, like Flickr, Amazon or Twitter was either a task for a library, or careful hand coding. In NetBeans 6.1, there is now a web service client code generator. How does it work? Select the "Services" tab, then open "Web Services" in the tree, expand the service you want to use, then click down the tree to pick which API call you want. Then you drag that API call into the text of your code where you want it and something like

	 try {
String since = null;
String sinceId = null;
String page = null;
String format = "xml";

RestResponse result =
TwitterWhatAreYouDoingService.getFriendsTimeline(since, sinceId, page, format);
//TODO - Uncomment the print Statement below to print result.
//System.out.println("The SaasService returned:
} catch (Exception ex) {

appears in your code. The example here queries Twitter for a status time line of friends. But this isn't the only code generated. Elsewhere in the your project, NetBeans will have created classes for RestResponse and TwitterWhatAreYouDoingService, along with a basic authenticator, which can take values from a property file or prompt the user with a Swing dialog. Now all that is needed is your own code to set up the parameters and handle the result. Pre-existing tools within NetBeans like the XML Schema designer, for when you don't have a schema and JAXB binding support, for when you do have a schema, can make that process a lot simpler too. Once you have JAXB set up for the result, then you can "result.getDataAsJaxbObject(...)", with a JAXB bound class as a parameter, and you get back Java object hierarchy ready for you to apply business logic. If you have a WSDL or WADL file for a service, you can import it into the web service list, though, in our experience, people just aren't making those files for their APIs, so it will be interesting to see how the NetBeans pre-installed set expands in the future.


At the other end of the web service equation is creating the service itself. NetBeans 6.1 brings RESTful web services to the IDE with Jersey the open source implementation of JSR331, and then makes the entire process even easier. To add REST services to a web application, you select "New->RESTful web services from entities". NetBeans then offers a list of known persistent entities to select from, asks what package and what paths you want for your web service and then generates all the required code. To check the service works, you can invoke "Test RESTful web services" and the browser opens with a REST test application, where you can browse the REST API, select entities from a tree then GET, PUT and DELETE on those entities, with different result formats. The entire process is relatively simple, and apart from a brief tussle with the Glassfish application server that is bundled with NetBeans, almost completely intuitive for a developer.

Converting entities to useful front ends is also the goal in another new feature, JSF CRUD generation. It allows you to take an entity in your web application, and generate JSF pages to create, update and delete those entities. This feature was due in NetBeans 6.0, and appeared in the betas, but vanished at release time. Now officially in NetBeans 6.1, it is a useful way of generating the scaffolding code which is so useful when rapidly prototyping an application, but that's about as far it goes.

NetBeans isn't just a Java IDE, with C/C++ and Ruby support as standard now. NetBeans 6.1 sees a number of improvements to the Ruby support. Debugging support has been hardened up to include the "fast debugger" option (which uses native debugging extensions) but "classic" debugging (which is Ruby based) is still supported. There's also more quick-fixes and hints for Ruby code which is integrated into NetBeans Tasks window, so you can see in one view what needs to be worked on in a Ruby project. Rails 2.0 is now supported in the IDE, but isn't shipped with NetBeans as yet; not a problem as there is now a fully fledged Ruby platform manager window letting you configure multiple installed versions of Ruby in the same way as NetBeans manages multiple installed JDKs.

The database services tab in Netbeans is where you can keep a list of database connections. 6.1 can now locate MySQL instances locally and makes them available in the database node of the services view where you can create, modify or drop tables, as you can with other database connections, or it can launch your preferred MySQL admin tool, specific to MySQL of course.

The NetBeans Rails support can now use these connections when creating a project, or you can stick with specifying your Rails configuration by hand. The NetBeans developers seem to be very sensitive to the need, when adding features, to not block users who want to use previous manual configuration processes. This leads to NetBeans being constantly assistive, rather than pushing a wizard-ish path. Of course this constant assisting can come at a cost, specifically in performance, with code analysis and hinting. In NetBeans 6.1, they've worked hard on this issue. In use, they seem to have hit the "just right" level; completion menus snap up, the lightbulbs and error markings on the left hand side of the editor feel like they update as you type each character rather than catching up after a second or so. In combination with this speedup, the memory footprint of the IDE is a bit tighter, it's more consistent over time and NetBeans initial start up is much faster.

Other additions of note are the Mercurial version control and Spring Framework support. Mercurial joins CVS and Subversion as a standard version control option, probably because the NetBeans development is moving to Mercurial. Spring Framework support for web applications includes setting up support at project creation and an editor with a deeper understanding of Spring XML files than just "It's XML".

There are asymmetries in NetBean's cross platform credentials; if you are on Mac OS X, you'll find that the Mobility pack and UML support are not installed as standard with a "full" NetBeans install. They are downloadable from the Plug-in/Update Center, within NetBeans, but UML has some JDK issues and you need to download MPowerPlayer SDK to work with the Mobility pack.

NetBeans 6.1 is a good quality point release; consolidating the improvements made in 6.0, rounding off the sharp edges and tuning up the engine inside. Well worth checking out at the price – it's free.

Print Version | Permalink:
  • Twitter
  • Facebook
  • submit to slashdot
  • StumbleUpon
  • submit to reddit

  • July's Community Calendar

The H Open

The H Security

The H Developer

The H Internet Toolkit