Today NetBeans 6.5 got released. Congratulations, guys! I’m primarily an Eclipse user1, but I keep hearing about NetBeans through the Java Posse and heck, I even subscribe to the NetBeans podcast to try and keep an eye on what’s up. Every time a new release comes out, I give it a whirl.
So this time, now I’m looking at 6.5. And it’s really nice on a lot of fronts. Most of the improvements in 6.5 aren’t directly relevant to me — they’re related to scripting languages I don’t use. What I’m particularly interested in is the core Java SE support. And NetBeans is really very good. It’s just not quite as good as Eclipse. Or (more likely) I can’t figure out a way to make it do what I want.
There are a couple of things I do all the time in Eclipse. First, ⌘-T
, which shows type hierarchies. But that’s putting it simply. If you pop it over a class, it shows the subtype hierarchy. Press it again and it shows the supertype hierarchy. What’s neat is that if you do it over a method, it greys out those classes that don’t have an implementation of that method.

But what makes it particularly useful is that it doesn’t pop up a proper window, just a little floater (I have no idea what it’s really meant to be called). As soon as you click somewhere, it disappears. This makes it incredibly fast to navigate code.
As far as I can see, the closest that NetBeans has is “File Hierarchy” on ^⇧F12
. But this pops up a big old clunky dialog box.
That’s one more thing about NetBeans — the key bindings are weird. And I speak as a long time emacs user. Now I’ll learn them (as it’s annoying to carry my customisations everywhere). But they conflict badly with a lot of Mac keyboards, because they’re extremely function-key heavy, and the mac likes to take over the function keys for itself.
The other Eclipse feature I use the whole damn time is “assign to local variable”. Yes, you can curse me for being damned lazy. But, I want to be able to type new PhoneImpl("01273", "123456");
then hit a key and get it assigned to a variable. In Eclipse, that’s ⌘-T L
. I couldn’t find a way to do it in NetBeans. The compiler knows what type it’s going to be. Why should I have to remember? Otherwise I’d be back in Emacs.
There are a couple of missing refactorings I use a lot: “Extract to local variable” and “inline local variable”. Both are easily replaced with cut’n’paste 90% of the time.
One particular feature that Eclipse and NetBeans both share is terrible defaults for exceptions. Here’s Eclipse’s default:
try { new URI("http://example.com/"); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); }
And here’s NetBeans.
try { new URI("http://example.com/"); } catch (URISyntaxException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); }
Both of these are fundamentally broken, and going to catch out dozens of unwitting programmers who don’t know any better. Yes, you can change the defaults, but most people don’t.
Anyway I don’t want you to think that I’m totally down on NetBeans. The new release maintains what I first saw in 6.1: a very fast, full featured IDE. It’s dead easy to get going, and there is loads of documentation. I find the project view to be much more useful and better organised than the eclipse view of the same.

I suspect that most of the problems I’ve been having are down to the fact I’ve been using Eclipse for 3 years, and NetBeans for a few hours at best.
One thing I did like very much is that there’s builtin Maven support. I downloaded the Java SE installation2, went to the plugins window and selected “maven”. About a minute later I had a working installation. And I can create new projects with archetypes really simply. And it’s dead simple to add new libraries as needed (I’m guessing it uses the nexus indexer to look stuff up). The only missing thing is the dependency viewer, but I can always run dependency:tree and dependency:analyze manually.
Funnily enough, where I think NetBeans really wins is the dynamic languages support. I’ve been following Tor’s blog for a little while and I’m incredibly impressed with what has been achieved in the Ruby support. For developing Ruby code, I head straight for NetBeans. Most of the issues I’ve outlined above are really specific to statically typed languages. For dynamic languages like Ruby (and now PHP and Python), what NetBeans gives you is a big win over the standard text editor.
Heck, the JavaScript support is pretty decent too. The first thing I did today was open up jslint4java and jump into fulljslint.java. That’s some pretty scary code. But NetBeans handled it with no issues at all. And it even pointed out a warning that’s easy to overlook (a duplicate hash key).
So, the big question is — am I going to use NetBeans? For any Ruby stuff, there’s no question. For Java stuff, I’m going to give it a try. After spending enough time with it to write this, I’ve already figured out enough stuff to use it a bit more successfully.
1 Apart from Emacs, Vim and TextMate. ☺
2 I didn’t like the look of the Java EE version — I don’t really need 3 application servers bundled, do I?
4 replies on “NetBeans 6.5”
you may be interested in Maven Best Practices with NetBeans have look 🙂
http://wiki.netbeans.org/MavenBestPractices
You don’t need 3 Application Servers. You only require GlassFish v2 if you are doing SoA development.
UML Module is not bundled anymore, and distributed via the Update Center.
NetBeans is very nice. I think it is the only Java IDE that I have ever recommended. I think the only thing that I miss from Eclipse is Subversive. But with integrated Subversion in Netbeans, I switched immediately.
Too many Eclipse projects are buggy, unfinished, un/badly documented, and even obscure and difficult to use in some cases. I rather goto an update center or have stuff that works and is well-documented bundled with the IDE, than go on a treasure hunt for add-ins. Maybe that is just me, though, since I do mostly Windows development using Visual Studio 🙂
@Nate: I agree you don’t need three app servers. Which is why I didn’t download the JavaEE pack. 🙂
As to Eclipse projects being buggy, well, I don’t use enough to notice. The core JDT in eclipse is good enough for the majority of the things I do.
On key bindings, you can change the key bindings. There are default profiles including Eclipse and Emacs.
The hierarchy view is at Navigate|Inspect|Hierarchy. It needs a couple touch ups to be on par with the one from Eclipse, but it does show you the hierarchy just fine; seems to have a bug in 6.5 where if you use it on methods it can spiral into infinite loops and you have to kill the IDE (that’s nice :-p). Sure, it comes up in a dialog, but you can hit escape just the same and it goes away. The dialog has borders, so it can be resized.
“Assign to local variable” looks like a good one to have. Prior to typing the code you could define a template and call it Dc and another called Dv. Dc:
${CLASS} ${NAME} = new ${CLASS}(${PARMS default=””});
Dv:
${TYPE} ${NAME} = ${VALUE};
So, you are still only typing the two extra keys including a meta key. Then you don’t have to type the =, spaces, or new.
Saves you even more typing. You type Dc or Dv and hit TAB and you are on your way. Once you have the values entered in the locations, press enter, and the cursor drops to the end of the line. You hit enter and keep on typing.
Of course it doesn’t let you change something like an anonymous class such as a thread extension and turn it into a local variable and then move methods you called such as .start() to the next line and be done; that is where the after the fact type action is handier.
On the other refactorings, they would be good to have as well 😀