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);

Sunday Jul 19, 2015

JMeter, Maven, and NetBeans IDE

Register the JMeter Maven plugin in your POM:



Then create a folder 'src/test/jmeter' in your Maven project. Install the JMeter plugin from Tools | Plugins and create a new JMeter Plan in the New File dialog (Ctr-N), in the 'src/test/jmeter' folder.

Build the project and notice that the JMeter Plan is run (click to enlarge the image below):

That's it. You can now run JMeter Plans during your Maven processes in NetBeans IDE.

Saturday Jul 18, 2015

FAQ: JMeter and NetBeans IDE

I've been looking at JMeter in NetBeans IDE, there's some great documents available on this combination:

While setting up JMeter in NetBeans IDE, I encountered two problems that are both easy to resolve when you know about these solutions.

  1. The plugin takes a long time to install. Unpacking hangs at 67%, during the unpacking of 'org-netbeans-modules-loadgenerator.nbm'. When this happens, don't worry, just wait a bit longer, for me it took about 10 minutes and then the installation succeeded. See here for this insight.

  2. The "External Edit" menu item fails to work. I.e, it's very convenient that you don't need to install JMeter yourself, but very inconvenient that the JMeter installation that the NetBeans JMeter plugin installs for you doesn't start up. Following these instructions, I ran the 'jmeter.bat' in the NetBeans user directory, found on the command prompt what the problem was, and then opened jmeter.bat and deleted the line 'set EVACUATION=-XX:MaxLiveObjectEvacuationRatio=20%'.

That's it. Now you're ready to use JMeter in NetBeans IDE.

Friday Jul 17, 2015

Getting Started with Arquillian in NetBeans IDE

Arquillian is JUnit for Java EE applications. (Plus more.) Read all about its features here. Markus Eisele wrote an article about the usage of Arquillian with NetBeans, sometime ago, here:


I took a look at Arquillian today, via a new Maven project that Aslak Knutsen from Arquillian has made available here:


Simply git the above and then go to File | Open Project in NetBeans and point to the folder that contains the POM. Because NetBeans is smart and able to recognize and parse the POM, it will open the Maven project and visualize its structure automatically, no import process of any kind is needed. Play around with the test class in the Maven project, i.e, add some new tests to it for the simple CDI sample or change the existing test, and then right-click the project and choose Test (Alt-F6). You'll see the integration of Arquillian with NetBeans IDE, i.e., the tests are run and the results are shown, as you can see here (click to enlarge the image):

Next, you can integrate with JaCoCo, to see your code coverage, as described here.

On Windows, I encountered the problem described here, which I resolved as described there, i.e., I set 'jbossHome' in the 'arquillian.xml' file. Then the first time the tests are run, there's a failure because WildFly cannot be found because it hasn't been downloaded yet. Next time you run the tests, the server is downloaded, thanks to Chameleon, and the 'jbossHome' property points to the correct location, i.e., in the 'target' folder and is then able to run the tests.

Thursday Jul 16, 2015

New Book: Learn Java with NetBeans IDE

"We chose NetBeans because we think it's the best IDE for beginners and because it will help you to learn faster. It's also easy to use, free, and runs on all operating systems."

In the latest big fat (660 pages) Murach book, NetBeans IDE plays a key role:

The cover features NetBeans quite prominently:

Get it here: https://www.murach.com/shop/murachs-beginning-java-with-netbeans-detail

Wednesday Jul 15, 2015

New JavaScript Formatting Features in NetBeans IDE 8.1 (Part 3)

Here's the new Braces formatting feature for JavaScript files in NetBeans IDE 8.1:

Tuesday Jul 14, 2015

New JavaScript Formatting Features in NetBeans IDE 8.1 (Part 2)

Here's the new Alignment formatting feature for JavaScript files in NetBeans IDE 8.1:

Monday Jul 13, 2015

New JavaScript Formatting Features in NetBeans IDE 8.1 (Part 1)

In NetBeans IDE 8.0.2, these are the Formatting options that relate to JavaScript files:

Notice that in NetBeans IDE 8.1, new features have been added here:

In the next two blog entries, we'll look at the new features added above.

Friday Jul 10, 2015

Refactoring Java in NetBeans IDE 8.1 vs. 8.0.2

It may seem small, but it can be very powerful, once you learn the new keyboard shortcuts... refactoring in the next release of NetBeans:

Compare that to the current release of NetBeans, where the majority of the keyboard shortcuts above are not present:

Thursday Jul 09, 2015

Android Release APK via Cordova in NetBeans IDE (Part 2)

Got some notes from my colleague JB Brock on yesterday's blog entry:

  • The process you describe will build the release apk, but if you click on the Run icon in NB, it will use the sim-android ant target and that is still defaulted to debug.  It does not run the release apk on your device unless you add the --release to the sim-android target as well.

  • When you set the --release to the sim-android target, it does indeed create the release apk, but it fails to launch on the device if you don't have the proper certificates installed.

    ERROR: Failed to launch application on device: ERROR: Failed to install apk to device:     pkg: /data/local/tmp/android-release-unsigned.apk

    So, while you can build it with --release, you cannot deploy it unless you have the proper keys setup.  That is another thing to look into.

Wednesday Jul 08, 2015

Android Release APK via Cordova in NetBeans IDE (Part 1)

To create the Android release APK via Cordova in NetBeans IDE, you need to add the '--release' flag to the 'build-android' Ant target in 'nbproject/build.xml'. Click to enlarge the image below:

The first time you build the project, the 'create-android' target will be run. That uses the 'add' command on Cordova, creating the 'android-debug.apk' and 'android-debug-unaligned.apk'. Subsequent builds of the project will automatically call the 'build-android' target, which uses the 'build' command on Cordova, where you have added the '--release' switch, which will automatically create 'android-release-unsigned.apk'.

Sunday Jul 05, 2015

News from NetBeans Zone

I have been involved with DZone for many many many years. I, quite seriously, go back a lot of many years with DZone. At the time, Rick Ross and Matt Schmidt were the driving force behind something called Javalobby. Later, Nitin Bharti was involved too, after which I interacted mostly with James Sugrue (who I still need to have a drink with in Ireland), and later still with Mitch Pronschinske. At the time, I was one of the editors on Javalobby.

Near the start of all that, I wrote general pieces of interest in the Java software world. For example, in November 2007, I wrote a pretty influential article on Javalobby entitled "What's So Groovy About Groovy?" It helped developers understand Groovy, in contrast to things-not-Groovy. I really enjoyed the interview format, especially interviewing multiple people, about a very clear and simple topic, e.g., "What is the Google Collections Library?" and Interview: Porting Open Source Java to Leopard. I liked the approach of getting to the core players in an issue and asking the core questions of them. The articles I wrote and discussions I started are relevant to this day, such as How do you parse HTML in Java?  That's it, that's all, that's what I wanted to do, write articles that focused on new and interesting things, right from the source, as well as gather information around an interesting theme.

Then at some point Javalobby became DZone. Fine. Instead of an editor, my role was that of moderator. There was a dedicated subsite for NetBeans, i.e., NetBeans Zone. We, i.e., the NetBeans community, posted about 3 or 4 brand new articles on NetBeans Zone every week. We piped NetBeans Zone through the Welcome Screen of NetBeans and also through planetnetbeans.org. At some point, a lot of NetBeans articles were in the "Five Favorite NetBeans Features" series, which were really helpful in getting people to understand the unique aspects of NetBeans. Quite a few of them were announcements about new NetBeans Platform applications. Or there were announcements about agendas for upcoming NetBeans Days. In short, there was a diverse range of articles that all related to NetBeans, of course, always on NetBeans Zone. Whenever there was a NetBeans Day somewhere in the world, we talked about and promoted NetBeans Zone, etc. We, i.e., the NetBeans community, have been promoting DZone for several years now, including it in our slide decks at conferences, talking about how this is a key place where the NetBeans community shares its insights and tips and tricks and news with the world, etc.

Together with NetBeans Zone, there was also a dedicated site for Eclipse and for JetBrains, i.e., for IntelliJ IDEA and related JetBrains products. However, there's no point in providing links to them... because none of these zones exist anymore. I discovered this by going to http://netbeans.dzone.com yesterday and finding that... it simply is no longer there.

Herewith is the correspondence with DZone that followed. It is so absurd that I shouldn't be alone in being aware of it. Also, I'm already getting e-mails from people who have articles published on NetBeans Zone, which no longer exist, and clearly whatever redirects have been set up are not working yet. Suffice to say, I am going to do everything I can to move over to jaxenter.com. Coman Hamilton, who runs jaxenter.com, indicated recently to me that if there were to be enough new content on a regular basis about NetBeans on jaxenter.com, that he'd set up a subsite dedicated to NetBeans. Since, over the years, we've been contributing 3 or 4 articles a week to DZone via NetBeans Zone, that's certainly enough content to make me think that this is the avenue we should take. Anyone that disagrees with me after reading the correspondence below is more than welcome to say so! I remain open to correction and admonishment. If there is anything in the below where I have overstepped the mark or where I have said something inappropriate, I am longing to hear about it.

Friday Jul 03, 2015

Quo Vadis Enterprise JavaScript?

In this shaky new world of JavaScript, here are the libraries I find to be very interesting:

When creating enterprise JavaScript applications, i.e., applications that are scalable and that need to be flexible and responsive, a combination of the above solutions could result in a maintainable application based on solid principles.

Here's an application I've been working on that combines some of the above, though I'm adding more of them over time:


The alternative to the above stack is AngularJS, which I think is a great solution if you buy into the entire philosophy of AngularJS. It's the "put all your eggs in one basket" approach vs. the "hey, let me build my own stack for my own needs" approach. It's also the "library vs. framework" debate. These debates have been going on forever. But, I think, in the JavaScript ecosystem, right now, this is pretty much where things stand.

Thursday Jul 02, 2015

Five Reasons to Apply for the NASA Java Opportunity

I mentioned the new job at a.i. solutions here yesterday. Sean Phillips, the great guy and NetBeans Dream Team member and author and many other things, you'll be working with, gave me the following 5 reasons for taking up the gauntlet and applying for the job!

  1. a.i. solutions provides Flight Dynamics and Launch Service Support to a large cross-section NASA and USAF centers and missions.

  2. Engineers at a.i. solutions are presented with a variety of space flight missions including LEO and International Space Station operations, Debris detection and collision avoidance and even Deep Space mission design.

  3. Software Engineers are given a significant degree of creative freedom to architect overall software designs while working directly with the country's top Space Flight Dynamics experts.

  4. The James Webb Space Telescope Flight Dynamics Ground System (JWST FDGS) ConOps integrates a variety of high fidelity modeling and simulation tools.

  5. The JWST FDGS faces design challenges including Parallelization, Big Data and custom Data Visualization.  The software engineers will be depended on to identify and apply the best software technologies to meet these challenges.   

And, need I say more, you'll be working on awesome Duke's Choice Award winning NetBeans Platform based network satellite software like this:

Wednesday Jul 01, 2015

Get Paid to Work for NASA with Java and NetBeans

Quite possibly the coolest job in the world for Java developers, with US citizenship, ideally with NetBeans Platform experience:

I love this bullet in particular up there: "Participate in inter-disciplinary teams to design and develop systems capable of supporting real-time satellite flight operations." That sounds amazing. :-) 

And if you're reading the above while thinking "Hmmm. I wonder what JWST means?" Then you should definitely take a look at this:


All the job details are here: https://rew12.ultipro.com/AIS1000/JobBoard/JobDetails.aspx?__ID=*A8E0B5D35817721B

Tuesday Jun 30, 2015

YouTube: NetBeans at JavaOne Brazil

During JavaOne Brazil last week, I made two short screencasts and published them on YouTube. They're both interviews, both with someone saying nice things about NetBeans!

Here's more from Diego in a blog entry: http://www.diegomagalhaes.com/netbeans-experience-revisited/

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

Monday Jun 29, 2015

YouTube: New Praxis LIVE Screencasts

One of the great people I met at NetBeans Day UK was Neil C. Smith, who is the developer behind the brilliant Praxis LIVE (@PraxisLIVE) project, the hybrid visual IDE for live visual coding.

Here's two screencasts he made about Praxis LIVE, recently, based on the demos he did at NetBeans Day UK.

Pretty amazing what can be done with the NetBeans Platform...

Friday Jun 26, 2015

International Synergy for Kendo UI Core in NetBeans

During JavaOne Brasil, quite a bit of work was done on the Kendo UI Core plugin for NetBeans! Opposite me at a restaurant (where we had endless heaps of great Brazilian meat and beer and so on) were sitting Mauricio Leal, Leonardo Zanivan, and All Pereira. I kind of mentioned to them that I was having problems with regular expressions for some pretty complex parsing of Kendo UI Core documents, the output of which is passed into the NetBeans code completion box.

It turned out that the three of them are a lot more experienced in regular expressions than I am. In fact, they'd been doing quite a bit of work with regular expressions recently and so the logic was still fresh in their minds. Right there in the middle of the food and plates and so on Mauricio, in particular, started hacking at the code. Leonardo and All also joined in. Then later I met with Leonardo and All at the Hackergarten, thanks to Heather van Cura:

And so it was that an international bond was forged between Heather (from the US), me (from the Netherlands), and Leonardo, All, and Mauricio (all from Brazil). Without Heather, we'd probably not have met up and without the Brazil guys we'd not now have a much better parsing. Compare the before with the after to see the difference, i.e., the same document is parsed, but now the information returned to the code completion box is far more complete:



The above is thanks to the pull that Leonardo made available:

There's still quite a bit more work to be done to get the parsing even more complete, plus we want to add caching to speed up the parsing.

Some people have encountered problems installing the plugin, which is because an implementation dependency is used, rather than public APIs. It should, in theory, work in NetBeans IDE 8.0.2, though not everyone has got it to work, i.e., installation fails because of conflicts between the implementation dependency and the already installed JavaScript2 Editor module. I have a workaround for this and will make a screencast about it soon.

The sources of the plugin is here: https://github.com/GeertjanWielenga/KendoNetBeans

And the binary is here: http://plugins.netbeans.org/plugin/60071

Thursday Jun 25, 2015

Trip Report: NetBeans Day Brasil

The first NetBeans Day Brasil ever (or, possibly, in a long long time) was held on Monday 22 June 2015 in the Oracle office in Sao Paolo, food sponsored by the Oracle Technology Network, and goodies provided by a variety of NetBeans partners, such as a copy of JavaFX Rich Client Programming on the NetBeans Platform, by Paul and Gail Anderson of the Anderson Software Group.

A key aspect to this event is that it is awesome that we now have a location for this in Brazil, i.e., the Oracle office sponsored this event with a very nice auditorium. Many thanks to Bruno Borges from Oracle for arranging this.

The content delivered at the event was really great. Except for myself, all the speakers were local and everything was in the local language, i.e., Brazilian Portuguese. That makes a big difference at these kinds of local events.

Topics included JavaScript/HTML5 with NetBeans, Nashorn, IoT, and an overview of NetBeans IDE itself. The full agenda is here. Speakers were Bruno Souza, Bruno Borges, Vinicius Senger, and Leonardo Zanivan.

A definite highlight was an overview of new features in the upcoming NetBeans IDE 8.1 by a great new active member of the NetBeans community -- Leonardo Zanivan.

Node.js, HTML5, JBoss Forge, and Other Awesome New NetBeans Features

Drinks and snacks were great, thanks OTN:

Everyone thought it was unfortunate that only about 1/3 of those who registered showed up, but those who were there were very enthusiastic at the end of the day and want to help promote this next time and they suggest that we use the local Brazilian media, e.g., message boards, etc, to promote NetBeans Day. However, since this was the first event of its kind in Brazil (or, in fact, in Latin America in general), it was really a "getting to know you" and "let's see what this is" kind of event, i.e., we're really just getting our feet wet here and now we have a base to start getting things going more seriously in terms of attendance at the next NetBeans Day in Brazil. We're also thinking of new strategies to ensure there's a closer correlation between registrations and attendance, e.g., maybe charging a few dollars for registration, for example, i.e., to make the commitment stronger to the event, though there are downsides to this approach, i.e., harder to get students to sign up then, etc.

All in all, a nice start, definitely worth repeating at a larger scale. Many thanks to the speakers and attendees for participation in this event!


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