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 'standalone.properties' file in the 'default package', with properties such as 'main.class' and 'project.name':

    controls.runonce.shortDescription=Call 'act' once for every actor.
    controls.run.shortDescription=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:

Sources: https://github.com/GeertjanWielenga/NetBeans4Greenfoot

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: https://github.com/GeertjanWielenga/YoNetBeans.

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!

Friday Jan 30, 2015

NetBeans has Integrated javac from jdk8u40-b22

The 'javac' from the latest JDK, that is, JDK 8 Update 40 b22, is now in NetBeans IDE development builds.

As a result, Lukas Eder should be happy to see sources of jOOQ now look like this in NetBeans (click to enlarge):

(Install the 'Dark Look and Feel Themes' plugin if you want NetBeans to look like the above.)

Instead of this (click to enlarge):

Related issue, thanks Lukas:


Tuesday Jan 27, 2015

Displaying and Processing Yeoman Generators and Commands

Each Yeoman generator, when installed, makes available one or more Yeoman commands. On the command line, you don't run a Yeoman generator, but a command provided by a generator. To make that distinction, the user interface of the Yeoman wizard has been changed a bit:

A generator that is available without having been installed is iconized by means of a green download arrow. When that icon is right-clicked, an Install action can be invoked, which will run "npm install -g generator-xyz" from within NetBeans IDE. Once that has been done, the "yo --help" command will be run again, automatically, to populate the upper view with the newly available Yeoman commands.

When a Yeoman command is selected and Next is clicked, the Yeoman command will be run, via "yo ko:app", or whatever the selected command is. Then the generated application will automatically open in NetBeans IDE.

From the above, it's very clear what the biggest advantage of Yeoman integration in NetBeans IDE will be: anyone will be able to browse through (the lower view above has built-in search and filtering features) the available generators and pick the ones they'd like to use directly in the place where the generated applications will be developed.

Monday Jan 26, 2015

Exposing Yeoman Generators to NetBeans IDE

The plan is to, as shown below, show all of the Yeoman generators and let the user select the generator they want to use.

Above, all of them are shown, including those already installed. The next step is to distinguish those that are installed from those that are not. If an uninstalled generator is selected, it will automatically be installed via 'npm install -g', after which it will immediately be used. If it is already installed, it will simply be used when selected, after Next is clicked above, and a folder is specified.

The biggest problem at that point will be ensuring that the generator runs non-interactively. Or to enable the user to enter somehow the arguments and parameters requested by the selected generator. Finally, the generated application will then automatically be opened into NetBeans IDE when the Yeoman process completes.

Friday Jan 23, 2015

Processing Output on the Yeoman Command Line

Here's where things are right now for Yeoman in NetBeans IDE. First, as pointed out yesterday, just like Maven projects from archetypes, you can create HTML5 applications from Yeoman:

When Next is clicked above, all the Yeoman generators that have been installed are shown, exactly as when you run "yo --help" on the command line:

(A feature I'd like to have would be to either have hardcoded or somehow generated the Yeoman generators that are listed here and then to let the user select the ones they'd like to have installed for them via NetBeans.)

(Also need to work more on the responses required from the generators. Right now, Enter is clicked automatically and the default generator is run.)

When Next is clicked above, the name of the selected generator determines the suggested project name of the application that will be generated.

When Finish is clicked, the generator is run in the location specified above, with the result shown below.

The next step is for me to add an 'nbproject' folder in there, with the correct content, so that the application will be recognized as a NetBeans HTML5 application. And then it will automatically be opened into NetBeans IDE, i.e., as soon as it has been generated via the steps above!

Thursday Jan 22, 2015

Parsing the Yeoman Command Line

The Yeoman command line, when you run "yo --help", shows you the available Yeoman generators that you have installed:

Integrating Yeoman into NetBeans IDE means that you want to let the user make use of those generators from within a New Project wizard, i.e., as discussed in this blog yesterday. So, here you go, thanks to Steve Souza (sitting on the couch at Concerto in Amsterdam next to me, great coffee and free Wifi hurray) and me:

The code for this is here on GitHub: YeomanHelpParser.java. You'll see the Yo executable is hardcoded, that's one thing I'll be working on, via a new item in the Options window.

Now that the above is done, things are looking pretty good. The user will select one of the installed generators (there'll also be a list of available generators that haven't been installed yet), click Next, and then the "yo" command will be called from NetBeans, the app will be generated, and will open automatically as an HTML5 project (from existing sources) in NetBeans. (JBoss Forge and LazyBones support for NetBeans should be implemented in a similar way.)

Wednesday Jan 21, 2015

How to Implement Yeoman in NetBeans IDE

I've been looking into what it would take to support Yeoman in NetBeans IDE. My initial idea was to use the dynamic actions mechanism (see it on YouTube here), to create something like the "External Tools" functionality in IntelliJ IDEA, where you can register Yeoman configurations as external tools, which means each configuration gets a keyboard shortcut, menu item, and toolbar button for invoking the configuration.

I showed the above approach to Ralph Ruijs yesterday and his immediate reaction was along the lines of: "That's just weird. If I want to create a new project via Yeoman, I'd expect to be able to go to the New Project wizard and have access to all the available Yeoman commands via a Yeoman category." Of course, it's a pity I can't use the dynamic actions approach but I agree that it doesn't apply so well in this context. So then I spent some time working on "dynamic project templates" instead of "dynamic actions", which is doable, but even more difficult.

And then... I thought about how Maven archetypes are suppored in NetBeans IDE:

When you want to create a Maven project from an archetype from the on-line Maven repository, you go to the above project template in the New Project wizard. When you click Next above, you see this dialog:

What that means for Yeoman (and for JBoss Forge, I believe) is that, assuming one wants to be consistent with the existing NetBeans IDE approaches, is to create an entry point like this:

When Next is clicked above, a dialog should appear similar to the second step of the Maven archetype wizard. At that point, "yo -- help" should be run (same as is done for grails and griffon in NetBeans IDE), which will then give access to the available generators, which should be made available in a drop-down list, which the user can then select, at which stage the generators are executed.

In other words, that means (1) no dynamic actions are needed and (2) no dynamic project templates are needed. Instead, a much simpler solution based on an existing NetBeans pattern is applicable here and, as you can see above, will provide a very clear entrypoint into Yeoman from within NetBeans IDE.

Monday Jan 19, 2015

Gulp for NetBeans IDE (Part 2)

Turns out there was no point in getting started making Gulp support for NetBeans IDE myself, since it's already part of daily development builds, and much better than my support was going to be.

For details on this and all the other awesome new features that are already available, go here:


Sunday Jan 18, 2015

Gulp for NetBeans IDE (Part 1)

The first part of Gulp support is complete. When the plugin is installed, the 'gulpfile.js', if it exists, is parsed and all the Gulp tasks are shown as child nodes of a new Gulp node in the Projects window:

Creating the above was trivial. Initially I got into all kinds of problems when I started by creating a new file type for Gulp files. But the solution ended up being much simpler than that. Using the NetBeans Project Type Extension Tutorial, I registered a new org.netbeans.spi.project.ui.support.NodeFactory for the org-netbeans-modules-web-clientproject project type.

All the code is here:


The next step I'm working on is being able to run those Gulp tasks from within NetBeans. Once that's done I'll publish the plugin in the NetBeans Plugin Portal.

Saturday Jan 17, 2015

Knockout.js in 2 Minutes (Part 3)

Instead of hardcoding the values, let's read them from a JSON file, "courses.json", which I have in the same folder as the "index.html" file:

        "name": "John",
        "courses": [{"title":"History"},{"title":"Geography"}]
        "name": "Bob",
        "courses": [{"title":"Science"}]
        "name": "Susan",
        "courses": [{"title":"Math"},{"title":"English"}]



Friday Jan 16, 2015

Knockout.js in 2 Minutes (Part 2)

If you liked part 1, you should squeeze in another 2 minutes and watch part 2!


<script src="js/libs/knockout/knockout-min.js" type="text/javascript"></script>

Name: <input data-bind="value: name, valueUpdate:'afterkeydown'" />

    Hello, <span data-bind="text: name"></span>.
<ul data-bind="foreach: courses">
    <li><span data-bind="text: title"></span></li>

<script type="text/javascript">
    var viewModel = {
        name: ko.observable("John"),  
        courses: ko.observableArray([{"title":"History"},{"title":"Geography"}])  

Thursday Jan 15, 2015

Knockout.js in 2 Minutes (Part 1)

Scratching your head over Knockout.js? Spend two minutes getting your feet wet here:


<script src="js/libs/knockout/knockout-min.js" type="text/javascript"></script>

Name: <input data-bind="value: name, valueUpdate:'afterkeydown'" />

    Hello, <span data-bind="text: name"></span>.

<script type="text/javascript">
    var viewModel = {
        name: ko.observable('John')  

Wednesday Jan 14, 2015

NetBeans Day in the Netherlands: 12 February 2015

During NetBeans Day 2014 in San Francisco, mention was made of more NetBeans Days being planned over the coming months. NetBeans Day Germany was held in Munich during December, hosted by Oracle, see the pic below, and read the report here.

In the Netherlands, the equivalent event to the above will be held on 12 February, i.e., less than a month from now, again hosted by Oracle:

Fill in the registration form and join the NetBeans community at the event:


Or, even better, if you're not available to be there, because you're in some other country, set up a NetBeans Day yourself! Drop me an e-mail (geertjan dot wielenga at oracle dot com) and the NetBeans team will help set up the day, contact an Oracle office if needed for the location and food, and assist in getting speakers for your NetBeans Day!

Tuesday Jan 13, 2015

Free: Learn NetBeans on Udemy

Free! An excellent course for anyone working with NetBeans IDE, covers all the basics, as well as many advanced features. It is unbelievable that a course this good is available for free, make use of the opportunity today!

Click the image above or click here to get directly to the site to get started with the course!

Monday Jan 12, 2015

Free: Learn Java with NetBeans on Android

Free! Start learning Java and NetBeans on your Android phone today. A step by step guide is available that can be installed on Android, with many instructions and a thorough guide to Java with many illustrations and insights into NetBeans IDE:

Go here or click the link above and happy learning!


Friday Jan 09, 2015

YouTube: Dynamic Actions in the NetBeans Platform

Sometimes you'd like your users to be able to create their own Actions at runtime, in addition to the Actions you may have predefined for them. Here's an example of how that would work, i.e., add new Actions and their Presenters to the User Directory, as shown here:

Thursday Jan 08, 2015

Classpath for Python Projects in NetBeans IDE

I've mentioned in this blog a few times recently the strides being made in rejuvenating the NetBeans support for Python, most recently in YouTube: Code Completion for Python in NetBeans IDE 8.0.2.

The newest development in that regard is new support for registering libraries on the classpath of Python projects (click to enlarge the image):

The above new feature isn't available in binary form yet, it's still being worked on. For the current state of the NetBeans IDE 8.0.2 plugin for Python, which includes quite some features already, including basic code completion, go here:


And, if you're lucky enough to be attending NetBeans Day in the Netherlands (12 February 2015), you'll find there'll be a session where the new Python features for NetBeans IDE 8.0.2 will be shown. Sign up for that event here:


Wednesday Jan 07, 2015

NetBeans Software for Explosive Ordnance Disposal & Clearance Divers

Operating from offices in Edinburgh, Scotland, and San Diego, California, SeeByte has achieved a position of leadership in the development of smart software for underwater vehicles, sensors and systems in both the Military and Oil & Gas sectors. SeeByte provides products and services to major government and commercial clients around the world and a number of these products are developed using the NetBeans Platform.

SeeTrack Military is the leading technology used by Explosive Ordnance Disposal (EOD) and Clearance Divers around the world, to achieve success in managing their off-board assets during dangerous and demanding missions. As a commercially available, equipment independent mission planning, monitoring and post-mission analysis tool, SeeTrack Military generates a single integrated picture of events from multiple sensors and platforms, providing actionable information and fast results when it matters most. Designed with the operator in mind, this unique system for rapid on-site analysis and fusion of sensor data has been effectively utilized within numerous military & security exercises, surveys and operations.


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.


« March 2015