Wednesday Feb 25, 2015

Free Open Source Tools for Maven, HTML5, IoT, and Java EE

I took part in another edition of the OTN Virtual Technology Day today. It started with being invited to contribute a screencast to the event, which I made especially for this occasionenabling me to think afresh about what it is exactly that makes NetBeans special and so I focused on Maven, HTML5, Internet of Things, and Java EEand then I also moderated the sessions live, i.e., answered questions that attendees asked while attending the session.

A week or two ago, the event happened in the Americas timezone and today it was the turn for EMEA. From 10.00 to 14.30 today, attendees in the Java track heard from a range of speakers, including Tori Wieldt, Bruno Borges, and Gerrit Grunwald. The "Free Open Source Tools" session looked as follows, click to enlarge, and notice some of the cool questions that were asked while attendees watched the screencast: 

There were several other questions after the above were asked, all really great and enthusiastic. Very nice to get the kind of feedback I'm seeing at these events. 

One more chance for attending the series of screencasts that constitute OTN Virtual Tech Days is for the APAC timezone–on 4 March–from 9:30 to 13:30 IST. Looking forward to seeing even more attendees there! 

The agenda can be viewed here:

Tuesday Feb 24, 2015

From Sublime to NetBeans?

What if Sublime were to be less cool than you thought and what if NetBeans were to be faster than you've assumed it to be? Right-clicking on an HTML file on disk and then opening it into Sublime takes 1 second, while with NetBeans IDE 8.0.2, if you're using the small HTML5 & PHP distribution (which doesn't need the JDK, only the JRE) it takes 9 seconds. Is 8 seconds a very big deal? To me, it sounds like NetBeans is an IDE that is 8 seconds away from being as fast as an editor.

Sure, performance and speed is a lot more than startup time. It's also about how quickly and easily things open and how smoothly you can switch from one task to another. But even here NetBeans has made great strides over recent releases and there's useful plugins like the Sublime feature (in fact, on the NetBeans Plugin Portal there are currently 6 different Sublime plugins) and the One Click Open Sesame feature to make it even more editor-like. Below are two screenshots, on the left of each you see Sublime, on the right you see NetBeans. Click the images to enlarge them and, unless I'm very much mistaken, the difference between them is 8 seconds faster startup time for Sublime, versus heaps of integrated features (which surely are worth waiting 8 seconds for) in NetBeans.

If you haven't tried the small bundle of NetBeans, i.e., the bundle aimed specifically at frontend developers, i.e., the HTML5 & PHP bundle, go here to get it (all free):

One feature I really like in Sublime, and it is also in the JetBrains products, is the multicursor functionality. I.e., you can have more than one cursor, i.e., on multiple lines. Lets you select code in multiple lines and change them at the same time, like rectangular block selection but not limited to a block. Seems like an extremely cool feature to me. However, the question does arise how often one needs that feature versus, for example, code completion for AngularJS directives, with embedded AngularJS documentation, as well as cutting edge KnockoutJS features, and native integration with Git, Gulp, Grunt, Bower, Node.js, Cordova, SASS, LESS, Mocha, Karma, Protractor, and Selenium, as well as integration with the Chrome browser, a library of out-of-the-box samples, and heaps more.

If you're going to respond to this admittedly contentious blog entry, it would really help if you've recently, i.e., over the last 6 months, made heavy use of both Sublime and NetBeans.

Monday Feb 23, 2015

YouTube: Search Everywhere in NetBeans IDE

What do you do when you don't know how to do something in NetBeans IDE? Do you search through random menu items? Do you go to Google and StackOverflow and mailing lists? Do you search through tutorials? What do you do? In this short YouTube clip, you'll learn about a feature you probably didn't know about or might soon look at in a different way.

While making the above, I realized I need to work a bit more on the Key Promoter plugin since not everything of interest I do with the keyboard is currently shown in the toolbar, yet.

Sunday Feb 22, 2015

How to Quickly Create New Java Files

I was looking at the Quick Search field a few days ago with a programmer friend and we were also discussing the New File dialog and how clunky it is to find how to create new Java source files there. So I thought, why not integrate relevant templates from the New File dialog into the Quick Search field?

Here's the result, i.e., notice that when I type "java", I can see (for the first time thanks to this new plugin I created) various Java file templates are available which, when clicked below, cause the relevant New File dialog to appear, all filled out with the values of the currently selected project. If no project is selected, or a file within a project, a message appears informing you of that requirement, since Java files need to be created within projects.

Source code:

Saturday Feb 21, 2015

Greenfoot and NetBeans (Part 2)

Recently I wrote about Greenfoot and NetBeans. Since then, Michael Kölling and his team have been working hard on simplifying the steps of moving a Greenfoot project to NetBeans. I tried out his simplified instructions today, with a build of a new release of Greenfoot, and found that in the previous blog entry, step 4 and 5 are no longer needed.

When you want to open a Greenfoot project into NetBeans, start by using the "Java Project with Existing Sources" wizard (in the New Project wizard, Ctrl-Shift-N) to import the project. For example, the "lunarlander" project, which comes with Greenfoot, looks as follows in NetBeans:

As described in the previous blog entry, you need to put "bluejcore.jar" and "greenfoot.jar" on the classpath of the project, as you can see above.

Next, right-click the project and choose Properties. In the Run tab of the Project Properties dialog, define the following (click to enlarge the screenshot below):

As you can see in the screenshot above, you need to the working directory to the root folder of the project. And, as you can also see above, you need to run "greenfoot.export.GreenfootScenarioMain" with three arguments, with no commas between them:

  • Scenario name.
  • Name of the world class (just the name, no .class extension).
  • Path to the 'greenfoot-labels' file from the Greenfoot installation (lib/english/greenfoot/greenfoot-labels).

Following the above steps, there's no need to create a properties file, which was defined in the previous blog entry, i.e., if the "greenfoot-labels" file is available.

Then run the project and you should see that it works perfectly, no need to fiddle with images and resources either, they're now found automatically:

Friday Feb 20, 2015

Sublime Text and NetBeans

Here's Sublime:

And here's NetBeans:

It pays to have both these tools in your toolbox. Switching between them is no problem. You can have them open at the same time, changes made in one are picked up by the other immediately. NetBeans is certainly significantly more powerful and expressive, look for example at the difference between code completion above.

Note: A common stumbling block is that when front-end developers go to the NetBeans Downloads page, they download the "All" distribution. The smart move is to download the "HTML5 & PHP" distribution instead. It is significantly smaller and lighter. Whenever a front-end developer has mentioned that they find NetBeans to be heavy and resource intensive, it has turned out that the developer was not using the "HTML5 & PHP" distribution. They were either using "Java EE" or "All" instead, both of which are the wrong distribution if you're "only" doing front-end development.

A question you might have is what's the difference in the size on disk of these two tools. Well, let's turn the question around and ask what's the value of having a JavaScript debugger built into your tool for stepping your code? And what's the value of having Git, Mercurial, and Subversion integration and local versioning support built directly into it? Don't you need those tools, and many others just like it, baked into the tool you're using, i.e., tested and naturally fitting into your development tool? Then what's the relevance of one tool taking up more or less space on your disk if in exchange for slightly more disk space you get the tools that you're going to need to install anyway if you're going to use the other tool?

And what's the value of being able to do this:

And this:

And this:

In short, these two are great to use together for frontend development. Want to do some quick editing, use Sublime. Want to do some more comprehensive tasks, e.g., smoothly set up an AngularJS project from scratch and check it into your GitHub repo, in a matter of two or three clicks, and then deploy the app to Android, debugging and styling it live there? Use NetBeans.

Thursday Feb 19, 2015

Tools for Teachers: Key Promoter for NetBeans

I wanted to be able to see the key events I'm typing or pressing in NetBeans IDE. So I created the Key Promoter plugin for NetBeans IDE. Helpful for me, and anyone else, using NetBeans IDE to teach anything at all, or do demos in NetBeans IDE, because the students/audience, whoever they are, can see what you're doing. Seeing the keyboard shortcuts you're doing helps confirm to your audience, and even lets them quickly take note of what you're doing, also because often they won't hear exactly the key combination as you're using it and talking about other things at the same time.

For the first time, the color of the label can now be changed (directly in the toolbar and not in some small place in the Options window), which is handy when you switch between different color schemes, themes, and look and feels.

In the above screenshot, I could potentially be saying: "NetBeans IDE lets you select a block of code across lines when you press Ctrl-Shift-R, as I am doing right now, as you can see in the toolbar, after which a block of code can be selected and changed simultaneously."

Get it here:

Wednesday Feb 18, 2015

Listening to Key Events in NetBeans IDE

Here's how to detect whether the user has pressed Ctrl-Tab. Add the following code within a Runnable annotated with @OnStart, in the "run" method implementation:

KeyboardFocusManager keyboardFocusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
keyboardFocusManager.addKeyEventDispatcher(e -> {
  KeyEvent kev = (KeyEvent) e;
  if (kev.getModifiers() == InputEvent.CTRL_MASK && kev.getKeyCode() == KeyEvent.VK_TAB) {
       StatusDisplayer.getDefault().setStatusText("you pressed ctrl-tab");
  return false;

The import statements:

import java.awt.KeyboardFocusManager;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import org.openide.awt.StatusDisplayer;
import org.openide.modules.OnStart;

Monday Feb 16, 2015

Maven and JAXB in NetBeans IDE

Let's take a look at custom binding declarations for JAXB in the context of the Maven JAXB-2 plugin, with NetBeans IDE.

Background reading:

Here's a basic outline of a structure in Maven in NetBeans IDE with a schema file and a binding file:

The schema file, i.e., the 'demo.xsd' file above, is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs=""
           elementFormDefault="qualified" attributeFormDefault="unqualified">
    <xs:element name="DemoElement">
                <!-- Demo 1: Globalbindings - in this example
                    DemoGlobalBinding1 will be bound to a XMLGregorian (default)
                    while DemoGlobalBinding2 will be bound as a Calendar via
                <xs:element name="DemoGlobalBinding1" type="xs:date" minOccurs="0" />
                <xs:element name="DemoGlobalBinding2" type="xs:dateTime" minOccurs="0" />
                <!-- Demo 2:
                    From the restriction the integer bindings could fit into a
                    java Integer, but as a xs:integer is unbounded, it is by
                    default mapped to a BigDecimal.
                    This demo maps DemoIntegerBinding2 to Integer
                <xs:element name="DemoIntegerBinding1" minOccurs="0">
                        <xs:restriction base="xs:integer">
                            <xs:enumeration value="1" />
                            <xs:enumeration value="2" />
                            <xs:enumeration value="6" />
                            <xs:enumeration value="8" />
                <xs:element name="DemoIntegerBinding2" minOccurs="0">
                        <xs:restriction base="xs:integer">
                            <xs:enumeration value="1" />
                            <xs:enumeration value="2" />
                            <xs:enumeration value="6" />
                            <xs:enumeration value="8" />

The binding file, i.e., the 'demo.xjb' file above, is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<jaxb:bindings version="2.0"
        <!--    Commented out for demonstration    
    <jaxb:bindings schemaLocation="../wsdl/demo.xsd">
        <!-- by XSD the value range is limited to the integer range so map it there -->
        <jaxb:bindings  node="//xs:element[@name='DemoIntegerBinding2']/xs:simpleType">
            <jaxb:javaType name="Integer" />


Both the above come from NetBeans user Matthias Bläsing, who writes that he extracted the above example from a project at work. The example shows that customization via a JXB binding file has a place outside of SOAP-based web services. For exampe, REST with XML in a client-side project could be an example. The starting point is 'demo.xsd', a fictional XSD file. It contains two examples for customization, which have made Matthias' life considerably easier:

  • Example 1. The default xs:date and xs:dateTime mapping to XMLGregorianCalendar is ugly, so  you can map it to Calendar.
  • Example 2. BigInteger is nice if you need it, but you might want to work with an Integer or int instead.
While 'xjc' correctly recognises <xs:minInclusive> and <xs:maxInclusive>, it fails to do so with enumerations. The 'demo.xsd' file contains two examples of each, one is customized, one is not, so that one can see the difference in the same result class, while 'demo.jxb' contains the customizations.

Now let's use the above files. Start by adding this to your POM:


Build the application and you'll see this:

The content of

package com.mycompany.mavenproject1;

import java.util.Calendar;
import javax.xml.bind.annotation.adapters.XmlAdapter;

public class Adapter1 extends XmlAdapter {

    public Calendar unmarshal(String value) {
        return (javax.xml.bind.DatatypeConverter.parseDateTime(value));

    public String marshal(Calendar value) {
        if (value == null) {
            return null;
        return (javax.xml.bind.DatatypeConverter.printDateTime(value));


The content of

package com.mycompany.mavenproject1;

import javax.xml.bind.annotation.adapters.XmlAdapter;

public class Adapter2 extends XmlAdapter {

    public Integer unmarshal(String value) {
        return new Integer(value);

    public String marshal(Integer value) {
        if (value == null) {
            return null;
        return value.toString();


Sunday Feb 15, 2015

YouTube: Find Recent File & Recent Edit in NetBeans IDE

When working with many projects and files in NetBeans, it is useful to be able to open the most recently closed document and to jump the cursor to the place where the last change took place. Do you know how to do these things and which keyboard shortcuts are applicable? Spend 4 minutes learning about this!

If you're watching the above and wondering how the toolbar displays in red the current keyboard shortcut and other actions, get the latest version of the NetBeans Key Promoter here:

Saturday Feb 14, 2015

[ERROR] Two declarations cause a collision in the ObjectFactory class.

The error message in the title of this blog entry seems to be causing a lot of people in the world a lot of problems. In this blog entry, I hope to be able to reproduce the problem and solve it, once and for all, for everyone everywhere, using a great tool to support you in doing so, i.e., NetBeans IDE. 

Let's start with this WSDL, which is useful in this context since it lets us reproduce the problem and then solve it:

  1. Create a new Java SE application in NetBeans IDE, named 'MoebiusIntegration', or any other name you like:

    Now you should see this:

  2. Go to the New File dialog and choose Web Services | Web Service Client. Click Next. In the WSDL URL field, paste the URL above and nothing else, i.e., do not fill in any field other than the WSDL URL field.  

  3. Click Finish. After a few moments, files are generated into your project structure and the first thing you notice is this big dialog:

    When you look in the Projects window, you should see this set of folders and files:

    In the Output window (Ctrl-4), you should see the following:

  4. Right-click the project in the Projects window and choose Build. The Output window now shows the following:

  5. Take note of the fact that there are different kinds of errors here, not all visible in the screenshot above, and the first below being the title of this blog entry and one that is a problem for many people, apparently, when I look on Google:

    • [ERROR] Two declarations cause a collision in the ObjectFactory class.

    • [ERROR] A class/interface with the same name "moebiusintegration.Reclamation" is already in use. Use a class customization to resolve this conflict.

    • [ERROR] This error is caused because on Windows you cannot have both "" and "" in the same directory.

    • [ERROR] This error is caused because on Windows you cannot have both "" and "" in the same directory.

Hurray! We've reproduced several JAXB binding problems. Let's now focus on solving them.

The biggest problem in solving these kinds of problems is that you're now going to go to Google and etc. There's hundreds (thousands, maybe) of developers who have encountered these kinds of problems over the years, there are many different solutions, each depending on the specific conflicts in the specific WSDL file, hence each solution being relevant for a subset of problems only. For example, in some scenarios, the -XautoNameResolution flag is helpful, while in others it isn't. It simply depends on the kind of JAXB binding problem you're dealing with.

The best thing to do is to start here, in the official documentation:

When you put the error message into a search in the official documentation above, you'll see this:

When schemas contain similar looking element/type names, they can result in "Two declarations cause a collision in the ObjectFactory class" errors. To be more precise, for each of all types and many elements (exactly what elements get a factory and what doesn't is bit tricky to explain), XJC produces one method on the ObjectFactory class in the same package. The ObjectFactory class is created for each package that XJC generates some files into. The name of the method is derived from XML element/type names, and the error is reported if two elements/types try to generate the same method name."

The first solution given for the above problem, right below the paragraph above in the documentation, is this:

"If the collision is coming from two different schemas with different target namespaces, then you can easily avoid the collision by compiling them into different Java packages. To do this, use <schemabindings> customization on two schemas and specify the package name."

An awesome contributor to this discussion on the NetBeans users mailing list, where this has been discussed over the past weeks, is Matthias Bläsing. He provided a solution that includes the binding customization referred to above. I used that approach to make this YouTube screencast today:

However, though the above fixes the ObjectFactory problem, the end of the YouTube screencast ends with a bit of a hack where I search through various files and rewrite bits of names to other names, which could be handled more gracefully. Matthias Bläsing to the rescue again who tells me that my approach with the rewriting is probably going to be wrong in the end: "Depending on what you changed in the XSD, the result might compile, but not work, as the elements are not recognized on the receiving side. The approach via customization is that I don't change the data definition, but only its mapping to the Java side."

So, hurray, Matthias has provided a new binding file which solves all the problems simultaneously:

<?xml version="1.0" encoding="UTF-8"?>
<jxb:bindings version="1.0"
            <jxb:package name="" />
            <jxb:package name=""/>
            <jxb:package name=""/>
            <jxb:package name=""/>
                <jxb:typeName suffix="Type" /> 
                <jxb:elementName suffix="Element"/> 
            <jxb:package name=""/>
            <jxb:package name=""/>
        <jxb:bindings node="//xs:complexType[@name='PersistentObjectOfInt']">
            <jxb:class name="PersistentObjectOfInt2" />
        <jxb:bindings node="//xs:complexType[@name='PersistentObjectOfString']">
            <jxb:class name="PersistentObjectOfString2" />

Alternatively, download it here:

Download the above file and put it anywhere in your project, e.g., in the META-INF folder, where the 'jax-ws-catalog.xml' file is found. Name the file 'binding.xml' or whatever you like:

Select the file and press Alt-Shift-L, which copies the file's full path to the clipboard. In NetBeans IDE, right-click on the 'MoebiusIntegration' node within the 'Web Service References' node and choose 'Edit Web Service Attributes':

Next, when the dialog opens, click the 'WSDL Customization' tab, scroll all the way down to 'External Binding Files', click Add, read the helpful information, click Yes, press Ctrl-V to paste the clipboard content into the Open dialog, and click Open. You should now see this:

Click OK. Then Click OK again. After a few seconds of processing, you should now see this and be able to expand the node as shown below:

But that's not all! Guess what? Not only do you now have all the client code... and not only are all the JAXB binding problems solved... you can drag all those red-bulleted nodes you see above, which represent classes, into your own Java code. For example, this is what my main method looks like initially:

Now I put my mouse on 'AddHardwareServiceOrder', which is the first node underneath 'CustomBinding_IMoebusIntegration':

Then I drag the mouse anywhere within my own class and when I release the mouse I see this:

Also notice that everything throughout the project, generated code and everything else, compiled. In other words, I now have a solid starting point for interacting with a service made available by the WSDL with which I started.

In upcoming blog entries, I'll look more closely at the binding.xml file and explain, via explanations received from Matthias Bläsing, what the entries in it mean, how it is hooked into the build process (and also how it can be done via Maven instead of Ant) and help understand the binding file's content. For the moment, you can simply take it and then adapt it to your own needs. Hope the above helps all those people out there struggling with these specific binding problems with JAXB.

Friday Feb 13, 2015

Trip Report: NetBeans Day Netherlands

After the recent NetBeans Day in San Francisco and NetBeans Day in Munich, the first NetBeans Day ever was held in the Netherlands yesterday, hosted in the Oracle office. Coffee, snacks, drinks at the end, all organized by Oracle, really helped to make the event a big success.

What also helped was the really diverse program:

The keynote was delivered by Adam Bien, world famous Java EE rockstar, who used the very latest NetBeans development build to demonstrate a range of cool things, from Angular, Bower, and Gulp, to executing JavaScript via Nashorn. Lots of great and powerful insights and great quotes from him about why NetBeans is really great, such as that it has everything available out of the box, including Git, for example, and that it's perfect for simply having everything available from the moment you have it installed.

Other sessions were by Timon and Kenrik Veenstra from LimeTri, John Kostaras from the NATO programming center, Joris Snellenburg from the VU University Amsterdam, Martijn Morrien from Netinium, Dalibor Topic (who introduced the OpenJDK and the processes around it) and Ralph Ruijs (who introduced the new tools he's working on in his free time for Python) from Oracle, and Pieter van den Hombergh from Fontys in Venlo. And I also did a presentation, at the start called "This is NetBeans", and at the end, "Extending NetBeans".

I liked the range of attendees at this eventpeople just getting started with Java (from the LOI MBO application developer course), as well as about 15 students who came with their lecturers from Fontys University of Applied Sciences in Venlo, together with high-end Java and JavaScript developers from Ordina and ING, as well as a range of independent software developers and consultants, and developers from specialized organizations, such as working for the defense force at NATO in Belgium and for the Dutch navy in Den Helder.

Aside from meeting again with many people I have met over the years, such as Timon, Joris, Johan, Remko, Marcel, Anthony, Steve, Eduard, Ingmar, Pieter, and my colleagues Ralph, Dalibor, Steven, Remco, and Eugene, it was great to meet many people I've been mailing with for years, such as Martijn from Netinium and Roy who has worked on the Wicket plugin for NetBeans, Vincent who I know from Facebook, and Kai (also from Facebook) who traveled all the way from Germany, as well as a whole bunch of people for the first time.

Already we have a date for the next NetBeans Day in the Netherlands: Friday the 13th of November! Mark that date in your calendar. In between, there'll be several smaller events, such as a NetBeans Platform training course at Fontys in Venlo, and a Java coding session with students from the LOI training course in Utrecht. Any other ideas for events in the Netherlands with NetBeans IDE or the NetBeans Platform are more than welcome! (And if you can make it to Munich on March 16, please sign up for NetBeans Day Germany here.)

Many thanks especially to Eugene Bogaart for all the logistical management involved in the event!

Thursday Feb 12, 2015

Presentation: "This is NetBeans!"

Anyone out there wanting to introduce NetBeans to your organization, university, college, school, or, why not, your family?

Here's a presentation that is pretty comprehensive to help you (the demos will be recorded and on YouTube soon):

Monday Feb 09, 2015

Extending the JavaScript Editor in NetBeans

Just about every other week, it seems like there's a new JavaScript framework out there. Each comes with their own idioms and constructs. When it comes to tools, the only logical way to be able to support the innovation in the JavaScript space is to have a modular, pluggable solution. When you look at the sources of NetBeans, you'll see that its top level structure implies a modular design:

What can we learn about the extensibility of the JavaScript editor by looking into the highlighted modules above? How hard is it to create a new module that provides support for some other JavaScript framework that isn't supported yet in NetBeans?

Let's look at each of the highlighted modules above and learn from them.


Take a look at the 'javascript2.prototypejs' module, shown above, and in more detail below, and you'll see it contains nothing more than one class:

That module is a direct result of this issue: and uses @FunctionInterceptor.Registration.

To see what that single class provides, take a look at how a Prototype sample looked in NetBeans IDE 8.0:

Specifically, look in the Navigator window above, which is not very expressive, compared to the Navigator in the screenshot below, which I took in NetBeans IDE 8.0.2:


The 'javascript2.extjs' module is more complex:

Here's part of the code completion that you see implemented via the code completion classes above:

In the 'model' package of the 'javascript2.extjs' module, the functionality provided is comparable to that provided by 'javascript2.prototypejs' module, which is the Navigator structure shown below (click to enlarge the image):

See this tutorial for step by step instructions to create the sample shown in the screenshot above:


In 'javascript2.requirejs', you can see that the HTML editor can be extended as well:

And you can see part of the above in action here:

The other modules are certainly more complex than the above though, the point is, supporting a new JavaScript framework is not necessarily a complex task.

Here are the annotations relevant to JavaScript extension points, more on these to come in future blog entries:

  • @CompletionProvider.Registration
  • @DeclarationFinder.Registration
  • @FunctionInterceptor.Registration
  • @ModelInterceptor.Registration
  • @ObjectInterceptor.Registration
  • @TypeDisplayNameConvertor.Registration

Saturday Feb 07, 2015

React.js and NetBeans IDE

I tried some small experiments with React.js in NetBeans IDE today. It more or less works and NetBeans IDE is certainly a productive environment for React.js:

I set up JSX from the command line to watch my 'js' folder and push to the 'build' folder: 

From the above, it would appear that JSX is like SASS, i.e., it takes one file and generates another file from it, so creating support for it in NetBeans IDE it could be based on SASS integration in NetBeans IDE. 

In the Options window, I tweaked the Error category for JavaScript files so that red error lines aren't shown in the editor (the red error marks aren't a problem, though the red error lines make the code unusable) because the background of my Error category is more or less the same as the background of the editor: 

I'm looking into creating an editor that understands (no error messages) and supports (embeds HTML syntax coloring and code completion) for files that make use of React.js. 

Friday Feb 06, 2015

Takari: Maven Incremental Build

Add this to your POM:


Make sure you're using Maven 3.2.1 or above. Click to enlarge the image: 


Thursday Feb 05, 2015

Trip Report: Topicus

I had a great time introducing NetBeans IDE at Topicus, which does software development in Deventer, in the Netherlands. To the outside geeky world they're primarily known as the home of Wicket.

The group consisted of about 20 developers and looked like this:

To me, the session was an opportunity for me to warm up for NetBeans Day Netherlands (still seats available, sign up!), which will take place one week from now, and where I'll do a series of demos at the start of the day, making use of these slides, which I created for the Topicus session:

Here's the main pieces of the technology stack used at Topicus:

  • Wicket
  • Maven
  • WildFly
  • Hibernate
  • Spring
  • Ember.js

They're increasingly moving away from Spring, and towards Java EE, have considered GlassFish/EclipseLink, and are now going for WildFly/Hibernate, and are going to move their front end towards Ember.js, though they don't seem 100% committed to that, though they do want a responsive client-side front-end, on top of a Java EE back-end using REST, of some flavor or other.

That's pretty much a standard scenario, I believe, in the Java ecosystem. They like Eclipse for its incremental compilation, while they dislike it for its Maven integration. Their setup didn't work in IntelliJ IDEA, and they're wondering why they should pay for something that has free competitors of similar quality, while they find NetBeans interesting for its Maven integration, but they don't like the performance of native Maven, which Eclipse avoids via its incremental compilations. Also since Maven is partly under pressure from the new world of Gradle, I'm hoping that the incremental compilation problem can be handled via Maven, thanks to, at some point, while the usage of JRebel by Topicus mitigates these problems to some extent.

Anyway, it was a great afternoon/evening and it must be wonderful to work in a company where there's a pizza oven in the backyard. Thanks, Martijn Dashorst, for organizing the event, and also because now I have several new topics to investigate and blog about!

Tuesday Feb 03, 2015

Greenfoot and NetBeans

When I met with Michael Kölling, from BlueJ and Greenfoot, when we discussed the relationship between those tools and NetBeans, Michael pointed out that BlueJ users are closer to NetBeans IDE than Greenfoot users. I took copious notes of our discussion, especially on the differences between BlueJ and Greenfoot, since that difference has never been completely clear to me. As Michael explained it to me: "BlueJ visualizes program structures and their execution, while Greenfoot uses visualization as the input to the program."

"Today we're building a game," is the angle teachers with Greenfoot in the classroom use, rather than "today we're going to learn about object orientation". Clearly, the two tools, though built on the same framework, have different approaches, with "motivation first" being the approach applicable to Greenfoot. It doesn't try to be as complete and formal as BlueJ and it's not a general IDE, while BlueJ is for teaching full programming. Anything in Java you can do in BlueJ, including Java 8. On the other hand, Greenfoot is just for two dimensional graphics, i.e., a very specific domain. Many programs you would never make in Greenfoot; it sacrificises generality for one thing only, to raise interest in programming. Then, after that, you potentially, assuming Greenfoot has raised your interest, go somewhere else to become a real programmer.

The underlying reasoning for Greenfoot came about upon the discovery that, increasingly, the first contact people have with programming is before university or technical college. Long before that, you've normally already decided whether programming is "for you". To "catch them early", the insight was that you need to enthuse people in the early stages of their development, i.e., you need to go to schools.

Anyway, all that having been said, let's see what it takes to take a Greenfoot project and work with it in NetBeans. It's less intuitive than BlueJ (as described here) but Michael and I worked through a process that works. My plan is to make a NetBeans plugin for converting a newly opened Greenfoot project in NetBeans to being a project that does step 2, 3, and 4 below automatically:

  1. Import Java Source Files. Use the 'Java Project with Existing Sources' wizard in NetBeans to import the Java source files created in Greenfoot, same as for BlueJ.

  2. Configure Classpath. Add the two JARs, greenfoot.jar and bluejcore.jar, from the Greenfoot distribution, to the classpath of the NetBeans project.

  3. Set NetBeans Project Properties. Set the main method to 'greenfoot.export.GreenfootScenarioMain' and set the working directory to point to the location of the sources. Click to enlarge the image below.

  4. Set Greenfoot Project Properties. Create a '' file in the 'default package', with properties such as 'main.class' and '':
    controls.runonce.shortDescription=Call 'act' once for every actor.
    run.simulation=Run the simulation.
    controls.reset.shortDescription=Reset the simulation.

  5. Figure Out Images and Resources. Images and resources aren't found automatically. Either put all images and resources into the default package or add 'setImage' method to the classes where images are used and do the same for the resources. Possibly something needs to change within the Greenfoot code to find the images and resources automatically when the Greenfoot JAR is used in standalone mode.

The whole project, here the 'Boids' project, looks something like this:

When you run it from NetBeans, you should see this, which is exactly what you see when you run it from Greenfoot. Take note of some of the properties shown above in step 4, which are applied to the viewer, e.g., the buttons you see in the lower part below:

As you can see from the above, a bit of tweaking must be done, which is why I think a small NetBeans plugin that does the above automatically would be helpful, i.e., what's needed is a "Greenfoot" tab in the Project Properties dialog of Java SE projects, which will let the user specify the above items to be added to the project and configure the project automatically to smoothen the transition from Greenfoot to NetBeans.

Something like this:


Note: See part 2 for enhancements to the above procedure.

Monday Feb 02, 2015

YouTube: Yeoman in NetBeans IDE

Here's a quick overview of the planned workflow for Yeoman in NetBeans IDE.

The sources are here and anyone is more than welcome to clone them:

Saturday Jan 31, 2015

Thanks, BlueJ: Code Outline for NetBeans

And this is why open source software, and the community around it, is so awesome—yesterday I spent some hours with Michael Kölling (read his Wikipedia entry here) while he was visiting here in Amsterdam, who explained to me (aside from many other things we discussed) that BlueJ and NetBeans work together very smoothly and that no plugins are needed for interacting between these tools.

That was great to hear, so as soon as I got home I tried it out. He was right. I made a movie about it and posted it on YouTube:

You'd think that that was "all", maybe, and that I'd end here by saying, "pretty cool, isn't it, how these tools work together and how different projects can strengthen each other, and how cool it is to meet enthusiastic leaders of the open source movement like Michael Kölling".

But there's more to this story! Benno Markiewicz, who is the most prolific NetBeans plugin developer over many years now, and who lives in Leipzig, Germany, saw the movie above today and... saw that BlueJ has a great Code Outline feature, which you can see vertically along the right side below which you can scroll up and down as a bird's eye view of your code:

And NetBeans doesn't have that feature, as discussed in this issue:

As you can see, various tools already have that feature, including BlueJ. Benno wrote today to say: "Because BlueJ's code is not so complex and is based on Swing too, I could extract the relevant classes from BlueJ, deleted some lines of code, and created a NetBeans module using them."

Here's the result (click to enlarge the image to see the whole context):

Get it here, where you can also see how to use it:

More features can be added to it, in time, but it's great to have this feature now available in NetBeans... all thanks to a chain of events that started yesterday over a coffee in a cafe in Amsterdam!


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.


« April 2015