Skip to main content

NetBeans 6 - my first 24 hours

Posted by michael_n on December 5, 2007 at 2:14 AM PST

My first 24 hours with NetBeans6.0 (final). I'm going to color a little outside the lines here, and soapbox a bit about "tools I use" (in NetBeans). Specifically: Spring 2.5, "vim", and Maven2.

First impressions with Netbeans 6

I had already been using & upgrading from NetBeans5.5, the 6.0 beta's, & the release candidates;
and the first thing I noticed with NB6 is the startup speed is much improved over the previous rc2.
On a (Linux) laptop, the NB rc2 was taking somewhere in the neighborhood of 10 seconds
(not sure exactly, I get distracted while waiting... short attention span) and now it's
thankfully down to a very focused 4 seconds. (update: ok, after adding in all those plugins I tend to use, this went back up. Memory makes a difference, too, of course. Startup time could be faster, though.).

First tasks with a new toy: customization.

Btw, it's really nice being able to run the same software on completely disparate
platforms. Big things like this get lost in the little details once a technology
(like Java) becomes ubiquitous.

Ok, here's my setup. I'm getting pretty good at this, since I've been doing it a lot. I've been running NB on Linux, Windows & Mac.

On Linux, just run the installer: chmod a+x, ./install, and the same GUI as on Windows & Mac
guides you through the basic steps:

  • select to install GlassFish & Tomcat 6 (already installed from previous releases)
  • option to import old NB 5.5 settings (I'll start over, just for practice)
  • Linux (and Windows) creates a desktop shortcut:
    • the Linux default launcher: /bin/sh "/opt/netbeans-6.0/bin/netbeans"
    • you can customize the launcher with options (for example): /bin/sh "/opt/netbeans-6.0/bin/netbeans" --fontsize 10 --laf javax.swing.plaf.metal.MetalLookAndFeel
    • (you could of course also install the substance LAF)

Time to install plugins.

People rant or rave about the number of plugins for this IDE or that, but
I've decided the perfect number of plugins per application is in fact 42. Strange, that is.
But seriously: any more than that, they simply aren't used. Less, and I feel limited, the platform isn't
extensible enough. (FireFox has been my strawman for this conclusion, but
I've had the same experience in using other IDE's, too. Or, Maven, for that matter.)

Btw, I'd love a NB plugin like FEBE + CLEO for FireFox -- a way to backup & bundle all my
NB plugins into a single re-installable installer!

But here's the essential super-short list of optional / out-of-the box plugins:

  • JUnit / testing related plugins: Now that JUnit4 is out (for quite some time actually), it's been a bit of a chore getting things to support the new features of this backward-compatible testing framework. Spring 2.5 now fully supports JUnit4, and I've had no problems with Maven2 under NetBeans with the annotation-style JUnit4 testcases. Everything pretty much "just works" (with one tiny exception: Profiling. I need to try this out again; I'm sure I'm missing something...)
  • Maven related plugins. Notes:
    • for an existing Maven2 project, don't "create new" projects in NB, just "open" the project. NB sees the pom, and opens the project.
    • If it's a multi-module project, the sub-modules are also recognized as projects.
    • "F11" compiles - actually executing a "mvn install", which also runs all your tests. (Remember: the somewhat misleading "install" goal means that the code is compiled, tested, and the artifacts (jars) are copied to your "local repository" (~/.m2) to be made available to other (local) projects dependent on them. On the other hand, the "deploy" goal pushes the artifact to your online maven repository.)
    • shift-F11 does a "clean" + "install"
    • you can right-click the project & run custom goals
    • you can right-click a single JUnit4 testcase (no "main()" necessary, no "suite" required, no need to extend TestCase) and choose "debug" or "run"
  • Other plugins: You'll definitely want to look into the other built-in (but optional) plugins. The short list: Developer collaboration, Mercurial, DTrace, Module Manager, RCP book samples, Log management, ... Ruby support, JMX, ... and the list goes on (well beyond 42)....

To install any of these 3rd party plugins, manually download the respective ".nbm" file(s), and in NetBeans go to: Tools > Plugins, "Downloaded", "Add plugins..."

And that's just the built-in plugins: see also the 3rd party plugins at the plugin portal.
My essential 3rd party plugins (for my particular needs) are:

  • jVi plugin for vi essentially, all the goodness of Vim in Netbeans (download jVi at sourceforge)
    • Download nbvi-FOR-NB-RC1-1.1.2.x6.zip - the newer, the better. The versioning is little ad-hoc. This is v1.1.2, x6 (x7, x8)
    • Unzip, select both .nbm files: "com-raelity-jvi.nbm" "org-netbeans-modules-jvi.nbm"
    • Optionally, you can install the NB patch: nb60m10-patch-for-jvi-07-07-01.zip
      (...it kinda works, but with quirks). Unzip & copy the files directly into your nb
      install folder, under platform7/modules/patches
    • Check out the customizations under Tools > Options > Advanced Options: see the Control-Key bindings, verify that Ctrl-V *is* checked, so you can use Vim-style "Visual Mode". Then, you can't use ctrl-v
      to "paste", but you can do Vertical editing (which is much cooler than pasting, imo).
      For example:
      •       ctrl-v jjjjj I // [esc]
            

      and you've just commented out a block of code (five lines).

      If you do lower-case "u", it'll undo just one minor edit at a time (ie, undoing one of the five comment-lines, rather than all five at once). If you install the aforementioned patch, the entire edit will be undone (just like in vim).

  • Spring support plugin (v1.1, released Dec 2, 2007) (see: http://spring-netbeans.sourceforge.net/, Install plugin: spring-support-plugin-1.1.nbm )

Speaking of Spring...

Spring Framework 2.5

If I may go on a tangent: the new Spring Framework 2.5 really, really simplifies your project configuration (compared
to Spring 1.2 or even 2.0). I know this has very little to do with NetBeans per se, but it should be noted that
there is nothing preventing you from using NetBeans for a Spring project (for example, you don't need the Spring IDE for a Spring project)-- quite to the contrary.
And if you haven't browsed through the Spring 2.5 updates, you really should take a look; here's a quick launchpad:

First and foremost (test-first!), Spring2.5 supports JUnit4.4 annotation-style
testcases. (Note: the abandoned gienah-testing project is no longer necessary to support this). As for the xml-style configuration (and, remember, it IS possible to have Java-style configuration (a la Guice)), the required XML has really been simplified. And with the NetBeans Spring plugin, you can (at the very least) use auto-completion in your bean configuration. In NetBeans, your Spring XML config shows up in a "Other Sources" folder in NetBeans, if using the standard Maven layout with a folder for properties and xml config in "{mymodule}/src/main/resources".

As just an (incomplete) example, with Spring 2.5 you can configure
a JMS sender and asynchronous JMS receiver all in POJO's, configuring the JMS broker
URL & JMS 1.1 destination (topic/queue) in a easy-to-edit "properties" file (as another side-note, ActiveMQ is very Spring-friendly to configure. Very nice.) The below example shows the new 2.5 properties-configurator (it allows a java properties file to be read, substituting properties into your Spring xml config):

<!-- 
   using the new (2.5) property-placeholder, eg, with properties
   jms.url=tcp://hostname:61616  and topic jms.dest=FOO.TEST
-->
<context:property-placeholder location="classpath:jms-test.properties"/>

<!-- pojo listens for incoming jms messages (asynchronous) -->
<bean id="msgListener" class="com.company.jms.MsgListener"/>

<jms:listener-container connection-factory="myConnectionFactory">
    <jms:listener destination="${jms.dest}" ref="jmsListener" method="processMessage"/>
</jms:listener-container>

<!-- a pooling based JMS provider -->
<bean id="jmsConnectionFactory"
    class="org.apache.activemq.pool.PooledConnectionFactory" destroy-method="stop">
  <property name="connectionFactory">
    <bean class="org.apache.activemq.ActiveMQConnectionFactory">
      <property name="brokerURL">
        <value>${jms.url}</value>
      </property>
    </bean>
  </property>
</bean>

Compare this to the old-style (Note: the xml below is just the property configurer -- which is just the first line in the above xml snippet):

 
<!-- old style (but it could be shorter) -->
<bean id="myPropertyConfigurer"
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  <property name="locations">
    <list>
      <value>jms-test.properties</value>
    </list>
  </property>
</bean>

It is pretty simple to integrate ActiveMQ into your Maven2 projects' testcases (if you're already using Spring 2.x and Maven2). Note that you'll have to add the apache repository to your pom.xml (or settings.xml).

More on plugins...

Ok: back to Netbeans... Other plugins that are of interest (to me, anyway):

  • PMD plugin Java source code analyzer download / unzip / install: pmd-netbeans60-2.1-bin.zip (update: you'll probably prefer SQE , which bundles PMD and various other software quality tools -- FindBugs, CheckStyle, Dependency finder, ... )
  • Mercurial: first, you have to install mercurial . And Mercurial requires Python, of course. For windows there's a simple "all-in-one" (BatteriesIncluded) installer that takes the thinking out of the installation. For Linux, installing anything is of course already straight-forward.
  • For the record, here's what I did install (this is from the built-in plugins -- the post-install gives me a nice copy-able list of what I just selected... that's also new in 6.0),
    • Ant 1.7.0 Documentation [2.22]
    • DTrace [0.1]
    • Developer Collaboration [1.2]
    • Eclipse Project Importer [1.32.0.1.2.43]
    • Extra Ruby Color Themes [0.50.0]
    • GWT4NB [1.3.4]
    • Generic Portlets [1.9.6]
    • GlassFish V3 Module [0.3.16]
    • JMX [3.0.0.30]
    • JMeter Kit [1.0]
    • Jellytools [2.3.121]
    • Jemmy Module [2.2.7.10]
    • JemmySupport [1.38.0.6.1]
    • Jindent [4.0.9]
    • Load Generator [1.7]
    • Log Management [1.5]
    • Maven [3.0.9]
    • Mercurial [1.4.1.42.1]
    • Module Manager [0.6]
    • NB JUnit IDE Integration [1.27]
    • NB JUnit [1.43]
    • NetBeans API Documentation [2.25]
    • RCP Book Samples [0.90]
    • Ruby Extra Hints [0.34.1]
    • Ruby RSpec Support [0.83.0]
    • Task List Editor Support [1.14.0.55]
    • User Tasks [1.28.3.55.16.7]
    • XTest Module [1.5.75.0.6.43]
    • XTest Samples [1.10.0]

Any comments on other plugins? favorites? diamonds in the rough? plugins with potential?

Open issues

One thing that I haven't tried yet with the shiny new NB6 is the Profiler.
But, on NB6.0-rc2, I couldn't get the Profiler to work with Maven2 projects as
wonderfully as with Ant-based projects. With Ant, profiling a project is a
breeze. With Maven... I couldn't really make it ... useful. I could attach to
a running process, but still, things weren't quite "Just working".
If I get it working (or if someone else has had a better experience), we can
all share & share alike.

As a workaround, I did a very Unix-only solution: you can pretty easily create
a directory of symbolic links in Unix (with NetBeans, you can't create a Ant project and a
Maven project in the same directory). For my Maven2 multi-project, I wrote a
shell script that took all my Maven multi-module "src" directories & merged them into a single src
tree in another directory; likewise, with my test source trees. Then, just have
Netbeans create a new Ant project based in this new directory. Feel free to run the Profiler, Debugger,
etc: any changes from the symbolically linked ant project are reflected
(via the symlinks) in the original Maven project. (Cough, hack, hack.)

But, I do have to note that the Profiler is really a useful tool -- another
bonus in a very solid IDE. (And although I haven't mentioned it, none of the
Netbeans 6 versions -- from the beta through to the release candidates -- ever crashed on me.
On Windows, Linux, or Mac. I'm glad to say that this is becoming the
expectation for software these days.)

In short, so far, so good.

-m

Related Topics >>