Why NetBeans?

Today it is time to summarize my experience with NetBeans. I am a user since version 3 (was it 3.4?) and my personal requirements increase not so dramatically like the features does in NetBeans. And so I am still a happy user.

I am not a jee developer so I can’t cover topics like JSF support, ruby or other ‘non-desktop’ features of NetBeans. For all features of the latest version please read this document.

The next points will be

My favorite features in NetBeans 6.1

  1. NetBeans is free, open source, platform independent and stable.
    There are several IDEs on the market, but Eclipse and NetBeans are open source and so they have the best price😉
    In comparison to Eclipse NetBeans was and is ‘really’ platform independent. That means you can use the same files for windows and Linux. But that’s not all: all platforms has the same support (unlike Eclipse e.g. for Mac OS).
    The latter point (‘stable’) is not true for the early milestones. My experiences with them were really bad, but e.g. the latest version 6.1 with all updates is very mature. I use it every day without a crash so far (although memory consumption is higher compared to previous versions)
  2. NetBeans is easy.
    NetBeans is easy to install and to use. There are several download-bundles so that you don’t need to go into the plugin hell, like in other IDEs. Simply download e.g. the Java-bundle and get the rest later through the plugin manager (Tools->Plugins). The NetBeans folks offer even a version for php development, where you can debug the code! (I tried it and it works under my suse linux, but the installation procedure was ugly…)
    All common actions have a keyboard shortcut or you can create one easily. Even for your ant tasks: Just click on the node which is on the left of the build.xml file (in the files window) and right click on a task. Then ‘create shortcut’. That’s it.
    NetBeans is easy for common tasks like

    • Editing
      I think the most important feature of all IDEs is code completion. In NetBeans you can do this via CTRL+SPACE. This will complete a variable, class or method name for you. One great example is to place the cursor after
      new JFrame().addKeyListener(new Key
      and select KeyListener. This will implement the listener automatically for you.
      With NetBeans 6.0 they introduced some code quality hints: if a variable is unused, if a method should be annotated, … To perform the actions associated with the hints (a yellow bulb on the left side) just click ALT+ENTER.
      Other editing-features are: formatting xml or Java sources via ALT+SHIFT+F, fix/organize imports via CTRL+SHIFT+I, create setters and getters via ALT+INSERT, SHIFT+F10 for context menu, maximizing the editor with SHIFT+ESC, jumping to another source code (CTRL+click a method or another object; CTRL+PageUp or Down), open any file with SHIFT+ALT+O
    • Refactoring
      rename of methods, classes via CTRL+R. Change method parameters etc.
      Try it via right click into a Java source and go to Refactor.
    • Running
      just hit F6 … and choose the main application before (right click on the project->main application)
    • Debugging
      hit CTRL+F5 to start debugging. To see the value of a variable hold the mouse over it. You can even evaluate expressions: select the expression with the mouse and hold the mouse over the selection. Or the old way: go to the Watches-Window and add the expression as ‘New Watch’. Even in this ‘add-watches’ text field you can use code completion! With this feature you can change the content of a variable easily. Warning: evaluate only expression without side effects, because otherwise the evaluation will change your variables!!
      Another feature will help those people where the application startup is expensive:
      (slightly) change the code and then go to the Run-menu->Apply Code Changes and continue with the changed code.
      Conditional breakpoints are available via right clicking on the ‘breakpoint rectangle’->breakpoint->customize. Then write any expression into the enabled line for ‘conditions’.
    • Web-start-enabling
      right click on the Java-project, then properties->Application->Web Start. The last time I used this it was a bit tricky to get it working…
    • Packaging
      just hit SHIFT+F11 or clean and build to get a jar file (which is usable via ‘java -jar’) and the other libs in the dist folder.
  3. NetBeans has a lot of plugins.
    Okay, there are a lot more plugins for Eclipse, right. Right at the moment😉
    The NetBeans community has some really cool plugins e.g. if you didn’t download the full bundle you can add the plugins easily via: Tools->Plugins. And they will work! I never failed to install a plugin. In Eclipse this was not always true.
    You should try the following plugins:

    • With the UML plugin you can create several types of diagrams. E.g. class diagrams. For those diagrams NetBeans offers a way to create them from the Java-source-files automatically.
    • Mobility plugin. Some times ago I developed mobidic (a mobile dictionary) and this even without ever having a smart Java-enabled mobile phone (using the emulator). Then I deployed the created files to a friend with such a mobile and … it worked!
      It is even possible to debug directly on the device (not only in the emulator). Read this.
    • The sqe plugin includes such great tools like findbugs, checkstyle and pmd to enhance you code quality. Go to this page to see how to install it in NetBeans.
      FindBugs is really nice, please try it and I am sure it will lead you to (at least) one bug.
    • For my TimeFinder project I use Spring Rich Client. Then I noticed that NetBeans could help even there with the Spring Rich Client plugin.
    • The Java Application framework support is a smaller project, but well integrated in NetBeans where you can easily create a desktop application (status bar, progress monitor, actions, …) within minutes. Just create a Java project and choose ‘Java Desktop Application’.
  4. NetBeans has good JUnit support.
    Default testing environment in NetBeans was and is JUnit (supported versions are 4.1 or 3.8). You can create a template JUnit-file via right clicking on the Java file->Tools->Create JUnit Tests or CTRL+SHIFT+U. I know that you should create the test before the class, but you should create the empty methods to let NetBeans create the test for you. After that write the test and make them passing (This is the way I go). NetBeans offers a nice UI to show the errors and passed tests. Click on the errors and NetBeans will guide you to the source code.
  5. NetBeans has a Java Profiler.
    Compared to Eclipse’s profiler the NetBeans profiler is faster and easier to setup (one click! really!). E.g. for a very simple project Eclipse’s profiler (within its standard settings) took 1 minute and 4 seconds. Where NetBeans profiler was ready within 4 seconds (nearly the normal execution time). I don’t want to talk about the time it requires to setup the TPTP stuff in Eclipse. The profiler for NetBeans comes with the standard Java-bundle so really no setup procedure. (To be fair: Eclipse’s profiler will be usable after some configuration.)
    With NetBeans 6.0 they introduced a new concept of profiler points, where you can define points in the source code where the profiler should do some actions (take snapshot, clear results, …). Read this for more details.
  6. NetBeans has good maven support.
    I didn’t try other IDEs with maven. In NetBeans you have to download the maven2 plugin then you will have a lot of features:

    • You can directly open any maven project. The pom.xml will be the project descriptor. So a change there will be visible in NetBeans after one second or so. E.g. if you add a new library you will see the added library in the Library node of the project window.
    • The main goals are accessible through keyboard short cuts or via mouse clicks as every other NetBeans project (clean, build, debug, run, test, javadoc)
    • ALT+ENTER on a missing class will ask if you want to search it in a maven repository and if it was found it will automatically add it to your pom.
    • A maven repository browser: Window->’maven repository browser’.
  7. NetBeans has other cool gimmicks
    • Subversion, Cvs and mercurial support; creating or applying patches etc. I personally prefer KdeSVN in combination with NetBeans subversion support.
    • Local history is a new feature introduced in 6.0. It its very handy to redo things that I changed the last week without having access to the underlying subversion – great!
    • You can create an HTML file from a Java source file (with correct highlighting). Go to File menu and click on “Print to HTML”.
    • Your translated project is just a few clicks away: Tools->Internationalization->Internationalization Wizard
    • You want to run your project with different startup parameter? Right click the project->Set Configuration->Customize.
    • Create a license header automatically for every file. (Please ask me if you need an English translation.)
    • To compare two versioned or unversioned files: select them and right click->Tools->Diff

NetBeans is not perfect

(Of course, that’s true for almost all software products)

At the moment NetBeans 6.1 does not offer:

  • An incremental compiler like in Eclipse (this will come with 6.5! and will be called compile on save)
  • A spell checker like in Eclipse
  • TestNG. This is very easy to setup in Eclipse and the hell in NetBeans.
  • Subversion client – you have to install your own command line version first.
  • Formatting of several files. E.g. via right clicking on a package->Tools->Formatting.
  • Searching through keyboard shortcuts
  • Select only some modules for the update process
  • Collect closed documents in a ‘trash’ (like in opera)
  • The collaboration plugin (Real time editing) is far from perfect. Read this for more information. Here Eclipse rocks!!

6 thoughts on “Why NetBeans?

  1. I have used nb for java, and I liked it a lot. I am trying to learn c now. Do the tools (like refactoring) work as nicely in the c plugin?

  2. Hi,

    a quick google search gave me:

    So, yes refactoring is supported. But in an experimental state.
    I tried the cnd some months before (under suse linux) and the only thing what I can say is,
    that NetBeans is a good environment for c development (run, debug, code completion worked).
    But parsing c code is somewhat difficult and so code completion worked only if you
    have the correct inlcude statements.

  3. UPDATE:
    1. real time editing is now really😉 usable in 6.1, try it out
    2. another missing feature: block selection also known as column selection
    3. toggle commenting with CTRL+/ or CTRL+SHIFT+C

  4. hi i like netbeans so much and i want to make mobile dic can send to me a souce code on mobility
    thank you

Comments are closed.