Tuesday Aug 11, 2015

Node.js: Free & Open Source Smart Tools

NetBeans IDE 8.1 Beta, released end of last week, has a heap of tools for Node.js application development. In fact, Node.js application development is the key feature of NetBeans IDE 8.1. In fact, if "awesome integrated Node.js application development" is your answer to the question "what's the key feature of NetBeans IDE 8.1", then you've really got the message!

The big features for Node.js application development in NetBeans IDE 8.1 are focused on (1) creating Node.js backend applications, (2) creating Node.js front-end applications with the Express framework, (3) editing Node.js code in a fast and smart JavaScript editor, (4) running Node.js applications, and (5) debugging Node.js applications.

Here's a quick screencast showing the basic features for Node.js backend application development, in which you create, run, and debug a Node.js web server in 3 minutes:

Or go here to see it: https://www.youtube.com/watch?v=hx6vXCdOYlA

More screencasts coming soon, including usage of the Express.js integration, i.e., web frontend development on top of Node.js backend applications.

But I like the smaller features especially, such as the code completion (with documentation included!) for Node.js modules in the JavaScript editor:

Join us, Node.js developers everywhere, NetBeans is a lightweight and free tool with a special new focus on Node.js application development! Lightweight? Yes, there's a special download, which includes the JRE (i.e., no need to install that separately anymore), focused on HTML5/JavaScript developers, which has tools only for those developers, i.e., no Java tools at all, only those tools you need as Node.js developers. Startup time of NetBeans IDE for HTML5/JavaScript, for me, is about 8 seconds, which surely is pretty fast. Get it here, for free: http://download.netbeans.org/netbeans/8.1/beta/

Monday Aug 10, 2015

Announcement: NetBeans IDE 8.1 Beta

Friday Aug 07, 2015

Customizable Code Fold Borders in NetBeans IDE 8.1

Those collapsed code folds can be pretty glary:

So, for the first time in NetBeans IDE 8.1, you can configure that white color:

Much quieter code fold borders now, set to Gray:


If you're curious what "Code Folding" and "Code Folding Bar" are for (though note neither of these two are new in 8.1), i.e., right above "Code Folding Border" in the second screenshot above, I have set "Code Folding" to Green below and "Code Folding Bar" to Blue, so that you can see the effect:

Finally, right below "Code Folding Border", in the second screenshot above, is "Editor sidebars background", which is also new in NetBeans IDE 8.1. I have set it to Red below, so you can see it:

See: https://netbeans.org/bugzilla/show_bug.cgi?id=243229

Thursday Aug 06, 2015

Released: NetBeans IDE 8.1 Beta

All the information is here: https://netbeans.org/community/releases/81

Wednesday Aug 05, 2015

Quickly See Implemented/Overridden Methods in Navigator in NetBeans IDE

Specifically for Java classes, the Navigator has become more expressive in the upcoming NetBeans IDE 8.1. If a method implements or overrides a method from another class, the Navigator shows you the class being overridden. It does that by means of an up arrow, which you can see, for example, in the "createKeys" and "createNodeForKey" methods in the screenshot below, where you can immediately see that those methods override/implement a method from the "ChildFactory" class:

Contrast the above with the below, from NetBeans IDE 8.0.2, where the information about implemented/overridden methods is not shown in the Navigator:

See: https://netbeans.org/bugzilla/show_bug.cgi?id=250553

Tuesday Aug 04, 2015

Enum Code Completion in NetBeans IDE

Enum code completion in NetBeans IDE 8.1:

Compared to previous versions, e.g., NetBeans IDE 8.0.2 below:

See: https://netbeans.org/bugzilla/show_bug.cgi?id=251669

Monday Aug 03, 2015

NetBeans "Find Usages" Includes Dependencies

Normally, in NetBeans, when you do "Find Usages" (Alt-F7), you get less than you might expect. Here, I'm doing "Find Usages" on org.jdesktop.beansbinding.Converter in the Client Editor sample project that is in the New Project wizard in the IDE:

The result is, unlike what you might expect, that the usages of the class are only found in the project classes:

However... in NetBeans IDE 8.1 (development builds already available here and a beta soon), you'll be able to add the following to the 'netbeans_default_options' of your etc/netbeans.conf file as described here:


After adding the above and restarting the IDE, you'll see that you can find usages in the project, as well as the project's dependencies:

The results include, as you might now expect, the usages of the class in the project, as well as the project's dependencies:

All the information is here: http://wiki.netbeans.org/FindUsagesDependencies

Note: All the screenshots above can be enlarged by clicking on them, to see their true resolution.

Sunday Aug 02, 2015

VisualVM Convincingly Wins RebelLabs Java Productivity Report

The RebelLabs annual Developer Productivity Report has been released and has focused very specifically on Java performance. Having gathered data from over 1,500 participants, the report defined key characteristics of performance teams and applications and found that the common cause of issues are inefficient application code and too many database queries.

Those of us interested in the tools domain, should take note of the following statistics in the report, in response to the question "Which tools do you use for application profiling?":

The above is an uncomfortable truth. In the related interview on JAXenter, see in particular the below:

Interesting and odd though that the statistic that is most surprising is immediately called into question. Whether you believe JProfiler should have won or Java Mission Control should have won (by the way, what the above paragraph does not tell you is that VisualVM is also free and shipped with Oracle's JDK, since JDK 6 Update 7), the fact of the matter is very clear. VisualVM won. By far. My guess for the reasons behind that statistic is that VisualVM is easy to get hold of, since it is in the JDK, and also very easy to use, thanks to the VisualVM team, in particular Jiri Sedlacek and Tomas Hurka. Kirk Pepperdine has also been one of several people involved in promoting this tool, including its plugin ecosystem and plugin extension capabilities, over many years. Great job, guys!

Saturday Aug 01, 2015

New NetBeans Books in 2015

Each year brings new books about NetBeans. That's a given, at this point in time. This year's crop is particularly fine, with Apress, Packt, and Murach all bringing out completely new titles around NetBeans. Jump in, the water's fine, there's something for everyone:

And maybe there are others that I've left out here? Let me know! We'd love to promote any new book that is either about NetBeans or that uses or refers to NetBeans in one way or another. 

Friday Jul 31, 2015

My Current NetBeans Look

Quite happy with it. I set --fontsize 14 in 'netbeans.conf' file and am using the first of the two Dark Look and Feel Themes, from the plugin of the same name in the Plugin Manager. Also, Consolas 18 Bold is the font I am using. Click to enlarge the image below to get the complete impression:

Thursday Jul 30, 2015

Cassandra in NetBeans Databases Node

Now the Cassandra node is correctly located within the Databases node:

Sources of the plugin are here: https://github.com/GeertjanWielenga/NetCassandraBeans

Wednesday Jul 29, 2015

Selenium for Java in NetBeans IDE

Selenium is a popular browser automation framework. There's a good introduction and examples here. Let's see how to use it in NetBeans IDE, for Java applications, without installing plugins. 

In the upcoming NetBeans IDE 8.1 (already available as development builds), create your Maven Java EE project, which will give you this:

In the New File dialog, you'll find Selenium test files:

When you select the Selenium Test Case above and click Next and complete the wizard, you'll have the new Selenium test file, as well as all the dependencies you'll need (click to enlarge the image below):

Right-click the application, choose test file, the rest runs, the browser opens, and the results are shown in the Test Results window.

Tuesday Jul 28, 2015

YouTube: Crossroads.js for Enterprise JavaScript Applications

A common routing solution for JavaScript applications is Crossroads.js. Using this blog entry, here's how to understand and get started with Crossroads.js:

Watch more NetBeans videos here: https://www.youtube.com/user/NetBeansVideos

Monday Jul 27, 2015

Cassandra Meets NetBeans IDE

Initial support for Cassandra in NetBeans IDE 8.0.2 is available. Get it here:


Install into NetBeans IDE 8.0.2, open the Services window (Ctrl-5), right-click the Cassandra node, fill in a host ( is the default), and a port (9042 is the default), and then browse the Cluster.

In the screenshot above "Explore From Here" opens the Cassandra node in a separate window, i.e., giving you more space, if you don't want to work in the Services window.

Double-click a table in a user keyspace (or right-click on it) to view its values in a table, as shown below. Choose "Dump Data" to print values into the Output window (Ctrl-4). Tables in system keyspaces are locked, i.e., data cannot be viewed.

In a future release of the plugin, the Cassandra node will be within the Databases node in the Services window, also Cassandra QL will be supported.

Sources are here, please fork and enhance: https://github.com/GeertjanWielenga/NetCassandraBeans

Sunday Jul 26, 2015

Viewing Cassandra Data in NetBeans IDE

Here's the latest status of Cassandra integration in NetBeans IDEyou can now open data into a sortable table or dump it into the Output window:

Source code is here for anyone who wants to contribute:


Saturday Jul 25, 2015

Setting Up an Environment for Cassandra/NetBeans Integration Development

After JCrete, a problem in continuing to work on the NetBeans/Cassandra plugin was that I didn't have Sven Reimers sitting next to me with his Cassandra cluster to which I connected for test data. So I had to set up a Cassandra cluster myself. Not a big problem with these instructions. Then I used the Cassandra Shell to create a keyspace, as described here. I liked the video data that Sven had available, so I used these Cassandra query scripts to recreate those, again via the Cassandra shell.

I also found the DataStax OpsCenter handy for taking a look at the structures I had created at this point:

Since I now had a running Cassandra cluster with live data, I was able to continue developing the plugin for NetBeans. As you can see, I can see the various structures from Cassandra in NetBeans, with some enhancements from last time, such as that the system keyspaces are separated from the user keyspaces (which will enable separate functionality for the user keyspaces) and that the data types are shown on the column nodes:

Next step is to find a nicer way to display the data from the user keyspaces. As you can see above, right now, everything is printed (neatly) into the Output window, ultimately some kind of grid is needed, maybe some kind of JavaFX component.

But the main win for the moment is that I now have a Cassandra cluster set up, with real data, that can be used while I continue developing the NetBeans plugin for Cassandra.

All the code for the plugin is available here: https://github.com/GeertjanWielenga/NetCassandraBeans

Friday Jul 24, 2015

Reverting Deleted Files

While checking the sources of the Cassandra/NetBeans integration into GitHub yesterday, something went very badly wrong and ALL the source files in my Maven project disappeared! Luckily I still had the Maven 'target' folder, which was untouched, I frantically searched for a Java decompiler online, decompiled the Java classes from the 'target' folder and then recreated my Maven project and eventually checked that in.

When I told Sven Reimers about this, he pointed out that in the IDE you can use the handy "Revert Deleted" feature. Let's say this is your project:

Now delete the Java source file you see above and right-click on the package (or anywhere in the ex-file's hierarchy) and choose History | Revert Deleted:

Hurray... there's the file again, the IDE still knows that the file existed:

Click OK above and your file is neatly returned to you, with all the content, and in the place, it originally had. Even after restarting the IDE, you'll still be able to do the above. Where is all this information stored? In the NetBeans cache directory (which is different to the NetBeans user directory), so, if you delete that directory, the information of deleted files will be lost and you'll not be able to revert again.

As a final step, go to the Options window and map "Revert Deleted" to a keyboard shortcut to make it an even faster process.

Of course, you should check things into a repository, e.g., GitHub. But normally, as in my case, you only put your GitHub repository together after you have created something significant enough to commit. If something, whatever it is, goes wrong during that initial process, the above procedure is extremely powerful, of course, and absolutely essential in these kinds of dire circumstances.

Thursday Jul 23, 2015

Cassandra in NetBeans IDE at #jcrete

Here at JCrete in a hacker session with Pierre Laporte (@pingtimeout), Sven Reimers (@svennb), and Thomas Darimont (@thomasdarimont) we managed to put together the start of Cassandra integration in NetBeans IDE.

The Cassandra Driver Core API is really cool and simple to use and in almost no time at all we were able to connect to a Cassandra cluster on Pierre's machine, to which Sven and Thomas were connected as hosts. Look in the Services window below and you'll see the Cassandra node, with one connected host listed, together with tables made available by the cluster, as well as the possibility of displaying data. The data visualization is the next part to work on, probably in an OutlineView.

Source code is here:


A potential next feature after that is syntax coloring for Cassandra Query Language, here's the ANTLR for that:


Wednesday Jul 22, 2015

Complex Node Hierarchies

When you're using the Nodes API, things can become a bit tricky, especially when you want to visualize different Node types on the same level within a hierarchy.

As an example, let's imagine our domain model represents music bands, e.g., 'Oasis', etc. Here's a very simple node hierarchy that simply lists the names of the bands, i.e., each Node below visualizes an underlying Band object that is defined by a name:

After you've done the above, you want to show the members of the band. So, now the Band object is defined by a name and a list of Members:

However, let's say each Band has a list of Members, as well as one Manager. Here things start getting a bit tricky. The ChildFactory class has a 'createNodesForKey' method that returns multiple Nodes, so your inclination would be to use that, something like this:

protected Node[] createNodesForKey(Band key) {
    int size = key.getMembers().size() + 1;
    Node[] nodes = new Node[size];
    for (int i = 0; i < key.getMembers().size(); i++) {
        try {
            nodes[i] = new MemberNode(key.getMembers().get(i));
        } catch (IntrospectionException ex) {
    try {
        nodes[size-1] = new ManagerNode(key.getManager());
    } catch (IntrospectionException ex) {
    return nodes;

What the above gets you is a structure like this:

However, you're more likely to want the structure below instead, i.e., a container Node for all the Members, together with a leaf Node for the Manager, of which there will always be one:

To achieve the above, I learned this approach from Sven Reimers during JCrete:

public class MusicBandContainerChildFactory extends 
    ChildFactory<MusicBandContainerChildFactory.Container> {
    private final Band band;

    public enum Container {
    public MusicBandContainerChildFactory(Band band) {
        this.band = band;

    protected boolean createKeys(List<Container> list) {
        return true;
    protected Node createNodeForKey(Container key) {
        switch (key) {
            case MEMBERS: {
                try {
                    return new MemberContainerNode(key);
                } catch (IntrospectionException ex) {
            case MANAGER: {
                try {
                    return new ManagerNode(key);
                } catch (IntrospectionException ex) {
        return null;
    private class ManagerNode extends BeanNode {
        public ManagerNode(Container key) throws IntrospectionException {
            setDisplayName("Manager: "+band.getManager().getName());
    private class MemberContainerNode extends BeanNode {
        public MemberContainerNode(Container key) throws IntrospectionException {
            super(key, Children.create(new BandMemberChildFactory(band), true));
    private class BandMemberChildFactory extends ChildFactory<Member> {
        private final Band bean;
        public BandMemberChildFactory(Band bean) {
            this.bean = bean;
        protected boolean createKeys(List<Member> list) {
            return true;
        protected Node createNodeForKey(Member key) {
            BandMemberNode node = null;
            try {
                node = new BandMemberNode(key);
            } catch (IntrospectionException ex) {
            return node;

    private class BandMemberNode extends BeanNode<Member> {
        public BandMemberNode(Member bean) throws IntrospectionException {
            super(bean, Children.LEAF);

Thanks, Sven!

Tuesday Jul 21, 2015

Empty Node Populated On The Fly

Sometimes you need to create a Node that initially has no Children:

Later, when something has happened, e.g., as above, a menu item is clicked and a dialog is filled out, you want to populate the Node hierarchy:

How to achieve this?

Start by creating this class, to centrally manage changes:

import javax.swing.event.ChangeListener;
import org.openide.util.ChangeSupport;

public class PropertiesNotifier {
    private static final ChangeSupport cs = 
            new ChangeSupport(PropertiesNotifier.class);
    public static void addChangeListener(ChangeListener listener) {
    public static void removeChangeListener(ChangeListener listener) {
    public static void changed() {

Next, make sure that your Children are created only when a property change is received:

import java.beans.IntrospectionException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import org.openide.nodes.BeanNode;
import org.openide.nodes.ChildFactory;
import org.openide.nodes.Node;
import org.openide.util.Exceptions;
import org.openide.util.NbPreferences;

class MusicBandChildFactory extends ChildFactory.Detachable<String> {
    private final List<String> bandNames;
    private ChangeListener listener;
    public MusicBandChildFactory() {
        this.bandNames = new ArrayList<String>();
    protected void addNotify() {
        PropertiesNotifier.addChangeListener(listener = new ChangeListener() {
            public void stateChanged(ChangeEvent ev) {
                String bandName = 
                                get("bandName", "error!");
    protected void removeNotify() {
        if (listener != null) {
            listener = null;
    protected boolean createKeys(List<String> list) {
        return true;
    protected Node createNodeForKey(String key) {
        BeanNode node = null;
        try {
            node = new BeanNode(key);
        } catch (IntrospectionException ex) {
        return node;

Finally, fire a property change at an appropriate moment, such as when the user has entered something into a dialog:

import java.io.IOException;
import javax.swing.Action;
import org.netbeans.api.core.ide.ServicesTabNodeRegistration;
import org.openide.*;
import org.openide.actions.NewAction;
import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;
import org.openide.util.NbBundle;
import org.openide.util.NbPreferences;
import org.openide.util.actions.SystemAction;
import org.openide.util.datatransfer.NewType;

        displayName = "#LBL_Bands",
        iconResource = "org/demo/enpotf/band.gif",
        name = "#LBL_Bands")
@NbBundle.Messages({"LBL_Bands=Music Bands"})
public class MusicBandsNode extends AbstractNode {
    public MusicBandsNode() {
        super(Children.create(new MusicBandChildFactory(), true));
    public Action[] getActions(boolean context) {
        return new Action[]{SystemAction.get(NewAction.class)};
        "LBL_Title=Band Name Definition",
        "LBL_Text=Enter Band Name:"})
    public NewType[] getNewTypes() {
        return new NewType[]{
            new NewType() {
                public String getName() {
                    return Bundle.LBL_Title();
                public void create() throws IOException {
                    NotifyDescriptor.InputLine msg = new NotifyDescriptor.InputLine(
                    Object result = DialogDisplayer.getDefault().notify(msg);
                    if (result == NotifyDescriptor.OK_OPTION) {
                        String bandName = msg.getInputText();
                                put("bandName", bandName);

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.


« October 2015