Thursday Apr 09, 2015

Sample REST Application

For some time in NetBeans IDE, there's been this example available in the New Project dialog:

The template above creates a new NetBeans Platform application that consumes services from the "Message Board" application that is available in the "Web Services" category in the New Project dialog.

I looked at the code of the "Sample REST Application" and, since it had been written some years ago, a lot of XML files are included, instead of annotations on TopComponents. And there are other problems in the example, too. Rather than updating it within the NetBeans sources, I think it's better to have the code available separately, so it can be worked on and extended further by anyone out there. So, here it is:

Here's the structure of the sample REST application, together with the Java EE application that provides the services:

Notice that the NetBeans Platform application uses Maven as its build system.

When both applications are deployed, you see the following, click to enlarge the image:

Related issue:

Wednesday Apr 08, 2015

22 June, 2015: NetBeans Day Brazil

In February, we had NetBeans Day Netherlands, while March was NetBeans Day Germany. In April, i.e., next week, it's NetBeans Day Greece, while NetBeans Day UK is in May. And, guess what, you can now also sign up for... NetBeans Day Brazil, to be held in June, the day before JavaOne Brazil:

Go here to sign up for this free event:

Tuesday Apr 07, 2015

New Book on JavaFX

Diese Buch bietet Ihnen einen schnellen Einstieg und umfassenden Überblick über die gesamte JavaFX-API. Schritt für Schritt zeigt es, wie Sie eine erste Anwendung bauen, wie Sie das eigene Datenmodell in der Oberfläche darstellen und editierbar machen und wie Sie die Anwendung mit JavaFX-Features anreichern, um ein modernes und ansprechendes User Interface zu erhalten.

Dabei lernen Sie u.a., folgende Möglichkeiten von JavaFX einzusetzen:

• Controls nutzen und anpassen
• Formulare layouten und eigene Layouts erstellen
• Charts/Diagramme erzeugen
• Animationen erstellen
• Audio und Video einbinden
• Anwendungen mit CSS stylen
• Nebenläufigkeit nutzen

Anhand eines durchgängigen Beispiels können Sie die besprochenen Inhalte praktisch nachvollziehen und vertiefen. Darüber hinaus können Sie das Buch bei der späteren Projektarbeit zum Nachschlagen einsetzen.

Das Buch richtet sich gleichermaßen an Einsteiger und Umsteiger in JavaFX.

The book is by NetBeans Dream Team member Toni Epple, and is available in German right now, as you can see above, from here:

Monday Apr 06, 2015

Mocha and Chai and NetBeans -- Unit Testing for JavaScript

Mocha and Chai work great with the unit testing support that is a standard part of NetBeans IDE for JavaScript files, as Adam Bien shows below:

Adam's blog on this is here:

Friday Apr 03, 2015

How My Life Would Have Been So Much Better If We Had Used the NetBeans Platform

Came across this today from some years ago. If I may say so myself, about something created and delivered by me myself, I'd say this is still really excellent content and should help anyone getting started creating their applications on the NetBeans Platform:

Once you've watched the above, do yourself a favor and get this book:

Thursday Apr 02, 2015

Updated NetBeans Twitter Page

Are you following NetBeans on Twitter? Do so, lots of info is spread in that way. Today the NetBeans Twitter page was updated and refreshed.

Click above or go here to get to the NetBeans Twitter page:

Wednesday Apr 01, 2015

Using Bower Package Manager

New support for the Bower package manager, a popular technology for JavaScript/HTML5 application development, is being worked on. Here's something to get you started, showing Bower's key features in NetBeans:

Also see this issue, which describes improvements made after the above was made, i.e., automatically the .bowerrc file is now created:

Tuesday Mar 31, 2015

YouTube: Debugger for JDK8’s Nashorn JavaScript in NetBeans IDE

Since the release of JDK 8 and NetBeans IDE 8, NetBeans has provided a built-in debugger for JDK8's Nashorn, the new lightweight high-performance JavaScript runtime built on top of the JVM.

With NetBeans IDE, you can add breakpoints to your Nashorn scripts and go through them when debugging your Java application. When you're debugging, you can step where no developer has stepped before: from your Java code into your JavaScript code.

To see this in action, watch this quick 5 minute screencast. Together with seeing Java and Nashorn being debugged together seamlessly, you'll see that Nashorn can also be integrated into a NetBeans module, i.e., you're able to extend NetBeans IDE via JavaScript!

Monday Mar 30, 2015

Extending NetBeans with Nashorn

Let's take our JavaScript/JavaFX code (for running Yeoman and displaying results in JavaFX) and integrate it into a NetBeans module. At the end of this blog entry you'll have a NetBeans module that looks as follows:

The 'yeoman.js' file is similar to the one blogged about here. Slightly tweaked, it's at the end of this blog entry.

It's registered in the layer file above like this:

<folder name="nashorn">
    <file name="yeoman" url="nbres:/org/netbeans/modules/yeoman/yeoman.js"/>

And here's the code in an Action (e.g., invoked from a menu item) that finds the JavaScript file and evaluates it via Nashorn:

Import statements:

import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javax.script.ScriptEngine;
import javax.script.ScriptException;
import jdk.nashorn.api.scripting.NashornScriptEngineFactory;

Here's the JavaScript, i.e., runs Yeoman and displays results in JavaFX:

/* global $OUT, generator, FXCollections, javafx, $STAGE */
var WebView = javafx.scene.web.WebView;
var StackPane = javafx.scene.layout.StackPane;
var Scene = javafx.scene.Scene;
var FXCollections = javafx.collections.FXCollections;
var Label = javafx.scene.control.Label;
var ComboBox = javafx.scene.control.ComboBox;
var VBox = javafx.scene.layout.VBox;
var HBox = javafx.scene.layout.HBox;
var stage = javafx.stage.Stage;
var output = $OUT;
var cleanedOutput = [];
output = output.substring(81, output.length - 553).split("\n");
for each(generator in output) {
    if (generator.length > 0) {
options = FXCollections.observableArrayList(cleanedOutput);
selectedGenerator = new Label();
comboBox = new ComboBox(options);
comboBox.valueProperty().addListener(new javafx.beans.value.ChangeListener({
    changed: function (observableValue, oldSelection, newSelection) {
var root = new VBox(10);
var box1 = new HBox(10);
var box2 = new HBox(10);
box1.children.addAll(new Label("Choose a generator: "), comboBox);
root.children.addAll(box1, box2);
var stage = new javafx.stage.Stage();
stage.scene = new Scene(root, 400, 300);
stage.title = "Yeoman Generator";; 

Further reading:

Saturday Mar 28, 2015

Combining Nashorn Scripting with JavaFX

Following from yesterday's blog entry, the question I had was: "Can I use -scripting and -fx at the same time?"

The answer is yes:

 /* global $OUT, generator, FXCollections, javafx, $STAGE */
var output = $OUT;
var cleanedOutput = [];
output = output.substring(81, output.length - 553).split("\n");
for each(generator in output){
    if (generator.length>0){
options = FXCollections.observableArrayList(cleanedOutput);
selectedGenerator = new Label();
comboBox = new ComboBox(options);
comboBox.valueProperty().addListener(new javafx.beans.value.ChangeListener({
    changed: function (observableValue, oldSelection, newSelection) {
var root = new VBox(10);
var box1 = new HBox(10);
var box2 = new HBox(10);
box1.children.addAll(new Label("Choose a generator: "), comboBox);
root.children.addAll(box1, box2);
$STAGE.title = "Yeoman Generator";
$STAGE.scene = new Scene(root, 280, 100);

The above runs Yeoman on the command line via JavaScript, thanks to Nashorn, and displays the result in JavaFX:

And this is how the code above looks in NetBeans:

Indeed, this would appear to be the start of a shell script enabling Yeoman to be used from JavaFX.

By the way, to do the above, and to use the info in Adam's recent screencast and in my blog entry from yesterday, you need a NetBeans development build and then use the Nashorn tab that has been introduced there, i.e., this is not in NetBeans IDE 8.0.2 but in a development build for the next release:

Friday Mar 27, 2015

JavaFX in JavaScript

Did you know you can code JavaFX in JavaScript? See here, click to enlarge it:

Even simpler than the above, it can also be expressed in JavaScript like this:

For some context, see Adam Bien's latest YouTube clip:

Tip: When using JavaFX with Nashorn, set the '-fx' flag in the place where Adam uses '-scripting' above.

As Adam shows, you can debug Nashorn:

Finally, the code snippets in the screenshots above come from this repository by Bruno Borges, which I learned about from him in an excellent session by Bruno about Nashorn at JavaLand this week:

Thursday Mar 26, 2015

Mobile Boilerplate and NetBeans IDE

It turns out NetBeans IDE has even more powerful tools than you thought...

Wednesday Mar 25, 2015

NetBeans Day Brazil: Monday, June 22, 2015!

During JavaLand, Vinicius and Yara and I decided... that the day before JavaOne Brazil (23 to 25 June in Sao Paolo) will be... NetBeans Day Brazil!

Here's a pic I took of them today at JavaLand: 

Watch this space for news and announcements about NetBeans Day Brazil! 

Tuesday Mar 24, 2015

A Simple Starter Project With Grunt

In your package.json file:

    "name": "simple-app",
    "private": true,
    "version": "0.0.0",
    "description": "A Simple Starter Project With Grunt",
    "repository": "",
    "devDependencies": {
        "grunt-contrib-copy": "0.4.x",
        "grunt-contrib-clean": "0.4.x"

In your Grunt file:
/* global module */
module.exports = function (grunt) {
        pkg: grunt.file.readJSON('package.json'),
        'Compiles all the assets and copies the files to the build directory.',
       [ 'clean', 'copy' ]

Monday Mar 23, 2015

29th May: (Free) NetBeans Day UK!

As announced at NetBeans Day during JavaOne 2014, we're holding multiple NetBeans Days throughout the world, in part to celebrate the 20th year of Java's existence.

In December, we had NetBeans Day Germany, in February NetBeans Day Netherlands, in March NetBeans Day Germany again, in April NetBeans Day Greece is coming up, and May... is NetBeans Day UK:

Sign up and join in:

And what will happen in June? Where in the world will NetBeans Day be held in June, July, etc? That's up to you! Propose a place where it should be held and the NetBeans community will work with you to set it up. 

Saturday Mar 21, 2015

Asset Management on NetBeans

I recently visited an asset management firm in the Netherlands, where various internal applications are created by the internal IT department. Here's their main application, used for asset management, i.e., stock trading and similar activities:

The above is yet another NetBeans Platform application. Especially the Window System, i.e., the docking framework, of the NetBeans Platform is considered to be very useful by the developers.

In the above application, data is pulled in from various web services, and managed in the application, which is basically a container for data. In fact, you could look at it as a highly customized browser. Had the application been a web app in FireFox, or some other existing browser, there wouldn't have been enough control over its functionality. Therefore, the developers created their own browser, to have maximum control over every aspect of the application. That's all that such desktop applications are and it explains the continuing need for desktop applications.

Here you see the application in action by one of its users, i.e., if you're managing assets, you typically have multiple monitors, showing multiple different applications. One of these, you can see on the far right, is the application shown above.

Other applications are being created on the NetBeans Platform by the same organization. For example, here you see an internal document management system, for printing, and similar activities. What's interesting is the lower part of the screenshot below, which is a JavaFX WebView component, containing a JQuery form in the bottom right. That means that a NetBeans Platform application can even integrate with JQuery; that's pretty cool, I think.

I always find it really interesting to come across applications such as the above two. They have in common that they're in the back office of an organization, that you're never going to read about them on the organization's website. In fact, I've been asked not to mention the name of the organization nor where it is.

In short, let's not base our understanding of the popularity of a technology on the analysis of GitHub or on seeing what people are using at conferences or using Google trends or things like that. Instead, if we want to know what's actually being used and done in the software domain, we need to really become anthropologists and go out into the field and meet people at the organizations where they work and see what they're actually doing. From the lowlevel subjective view, something higher level objective can maybe be extrapolated, and not the other way round. Indeed, that's a lot of work and much more difficult than running some scripts to analyze GitHub. But any other approach simply neglects the scenarios I've been describing in this blog over the past 10 years, where few of the applications I've encountered are on GitHub, even fewer are described on the company website, and almost none of the developers go to conferences, so all of these use cases fall under the radar.

Friday Mar 20, 2015

Human Rights, Amnesty International, and NetBeans IDE

At the headquarters of Amnesty International  in the Netherlands, quite a lot of interesting work is being done with NetBeans IDE. In this blog post, I'd like to briefly share the basic details of one of these projects.

With the Urgent Action App, created by Amnesty in Amsterdam, currently only available in Dutch though that will change, you're able to very quickly become engaged in human rights campaigns by efficiently signing petitions and sending e-mails to protest human rights abuses.

The app can be installed onto either Android or iPhone.

The technology stack for the backend of the Urgent Action App includes Java, Java EE, GlassFish, and NetBeans IDE. RESTful web service calls from the frontend, created in AppMachine ( are integrated into a Java EE backend that does the following:

  • collects registration data from users of the app who join the action network by filling in their details
  • stores data when  users sign forms in support of an action around human rights abuses
  • periodically creates a petition list from the support forms and presents them to applicable organizations and representatives
  • helps to show the level of support for a particular action and ensures that a petition can't be signed more than once

Below, you see a photo of Amnesty International software developers, from left to right, Bert Menting and Ed van Velzen, with NetBeans IDE 8.0.2 on their laptop, in the Amsterdam HQ office of Amnesty International in the Netherlands. 

Among many other features that they like in NetBeans IDE are the smooth integration of NetBeans IDE with GlassFish, the ease with which RESTful web services can be developed via helpful templates in NetBeans IDE, together with advanced Java coding features, such as "Find Usages" and the built-in free Java Profiler. They also appreciate the fact that NetBeans IDE is free and open source software. 

Great to see human rights work being enabled and empowered through tools and technologies that include Java, Java EE, GlassFish, and NetBeans IDE!

Thursday Mar 19, 2015

NetBeans at JavaLand

Next week I'll be at JavaLand. Looks like most of the "thought leaders" in the whole Java world will be there, when you look at the program:

A session I'm doing is on Tuesday, 24 March, from 12:00 to 12:45. Looking forward to it!

I interviewed Markus Eisele from the JavaLand organization when it was launched, last year:

Wednesday Mar 18, 2015

Microservices, Java EE, and Adam Bien at Blue4IT

Blue4IT is a software organization specialized in Java, based in the Netherlands. Last night they hosted the always entertaining and profound Adam Bien:

I thought he was really in top form, especially since he'd just flown in from Munich after having done the keynote session at NetBeans Day Germany the day before.

At some point I started tweeting his pithy wisdom and unfortunately at some later point my battery died. Until that stage, here's the key thoughts I picked up from him in his typically "lean" manner of looking at things:

No one embodies "lean" more than Adam Bien. Hmmm. "Adam Lean" would be a more descriptive name. The evening was really enjoyable, great catering too, looking forward to more of these at Blue4IT.

Tuesday Mar 17, 2015

Trip Report: NetBeans Day Germany 2015 (Part 1)

Not long ago, in December 2014, the Oracle office in Munich, Germany, was used for the first time to host a NetBeans Day. It was a big success. At that event, we immediately decided we wanted to have another day just like it and soon! In the meantime, NetBeans Day Netherlands has taken place, while NetBeans Day Greece, NetBeans Day UK, NetBeans Day Belgium, NetBeans Day Poland, and NetBeans Day Sweden are being planned, over the coming months, leading up to the next NetBeans Day at JavaOne later this year, which might be prefaced by a NetBeans Day in San Diego, too! (Missing your country in that list? No worries, contact me if you want help in setting up an event in your part of the world.)

Yesterday was the second Oracle-sponsored NetBeans Day in Germany, i.e., in the same place as where we were in December last year. There were a lot of topics to attend throughout the day, so during the lunch break the room was split into two, so that we were able to run two tracks, both of which were well attended, with a wide range of topics, from HTML5 to Raspberry Pi to Oracle Developer Cloud Service and more.

It was a fun time!

Rock star Adam Bien's view, on one side of the room, was as follows:

This was the whole group before lunch, i.e., before the room was split:

Adam Bien started the day by talking about HTML5 and JavaFX. Using a development build of NetBeans from the day before, he showed several cool new features, such as Gulp support, as well as Nashorn debugging in NetBeans IDE:

Kirk Pepperdine, performance guru and more, talked about the latest features in Java 8, focusing on a range of topics, though not sticking primarily to Lambdas and Streams, as normally happens at Java 8 sessions, for example, this was handy and illuminating:

Dalibor Topic, project manager of the OpenJDK, talked about the current state of OpenJDK and JDK 9, as well as explaining some interesting concepts and processes, such as the Java Enhancement Process:

After lunch (lots of healthy fruit and sandwiches), the room was split and several interesting sessions were held, such as by Jens Deters on Java embedded and the Raspberry Pi:

And Thomas Kruse showed a lot of code in his presentation on AngularJS and NetBeans IDE:

It was pretty cool to see Thomas using the "Dark Look & Feel Themes" plugin while talking about HTML5, i.e., like a lot of (most? all?) JavaScript developers, Thomas likes a dark background in his development tools:

Despite the dark background, the code was clearly visible throughout the room, the font size being enlarged so that those in the back could see it too.

One of the other sessions focused on Duke's Choice award winning "DukeScript", a new technology for creating cross-platform mobile,  desktop and web applications, which was explained in detail and with code by Toni Epple himself:

Paul and Gail had an excellent session on JavaFX and the NetBeans Platform, half of which you can view right here (the other half was not recorded because the disk was full):

Paul and Gail are from San Diego in the US and are interested in holding a NetBeans Day there, right before JavaOne, that would be great, I think. They also brought two copies of their great heavy new book with them "JavaFX Rich Client Programming on the NetBeans Platform", one of which was won by Stefan Gürtler from Transver in Munich:

Other sessions, of which I have no photos since I was one of the speakers or at a conflicting session, including a session on teaching with NetBeans IDE, mainly by Karsten Sitterberg, about how NetBeans is well suited as a tool for teaching Java. In that context, I introduced the NetBeans Education Community and the NetBeans Teachers Community on Google+. At the same time, Benno Markiewicz, the most prolific NetBeans plugin developer in the world, was explaining to a packed out room how to use the NetBeans APIs and create new plugins similar to the awesome ones he has been making.

I also did a session on the Oracle Developer Cloud Service (ODCS). I went through the features offered by ODCS which is a really comprehensive development platform in the Cloud, including Git, a bug tracker, Hudson, and Wiki. Watch the videos shown during the presentation here.

For those who stayed a bit longer, the day ended with a really nice Greek meal!

Almost forgot to mention one thing because it's such a typical occurrence to me at this stage—I again met a whole bunch of people I had never heard of before using the NetBeans Platform. It continues to surprise me in all the shortsighted "the browser is everything now" assumptions that greenfield projects, i.e., from scratch, are starting up all the time on the Java desktop for all the old reasons, that continue to be true, e.g., cross-platform, reliability, stability, etc, which when coupled with the modularity of the NetBeans Platform, together with its rich set of GUI components and programming techniques, makes for an absolutely killer combination.

It was a really enjoyable day, amazing how much was packed into it, many thanks to all the speakers and attendees! Special thanks to those who came from far, such as Allesandro from AirMosaic in Italy, Michal from Sabre in Poland, and Paul & Gail from the US. The next NetBeans Day, i.e., part 2 of this blog series, will be sometime after JavaOne this year, which will include content from JavaOne. Many thanks to the Oracle office in Munich, especially Peter Doschkinow, for making these events possible.


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.


« July 2015