Saturday Aug 31, 2013

Quote of the Year Re JavaScript and Java

Here's the quote of the year for me:

I think that eventually the technical debt involved with writing large (50K-100K line) Javascript-based (non-type-safe) applications will become so huge that there may be a revival in Java based client applications to reduce maintenance costs, as well as, the desire for better performance and richer, less restrictive technical capabilities.

From a commentor here on

Friday Aug 30, 2013

Maven, Java EE 7, Backbone.js Mashup

Here I've got a Java EE 7 backend, using JPA and EJB, together with an HTML5 frontend, using Backbone.js and HTML, all defined within the same Maven application:

This kind of mixed Java EE 7 / HTML5 application can be created from templates and wizards in NetBeans IDE 7.4.

When deployed to a Chrome browser, where the NetBeans Chrome plugin is installed, you have bi-directional integration available between the browser and the IDE, as well as when you're using the embedded WebKit browser, i.e., JavaFX WebView:

Thursday Aug 29, 2013

How to Set Up GlassFish Sources in NetBeans IDE

Here's where I find the GlassFish sources:

Let's set up the 4.0 branch of the above sources in NetBeans IDE. In the Team menu, use the Subversion tool to point to the above URL:

Click Next and then pick the 4.0 branch:

While the check out is taking place, add the folder where you're doing the check out to the Favorites window (Ctrl-3), which you can do by right-clicking in the Favorites window and choosing "Add to Favorites"...

...while also opening the Output window (Ctrl-4)...

Via the above two tools, you can monitor the check out as it happens. You'll see how far along things are.

When the check out is complete, right-click the root node, which is "4.0" above, in the Favorites window, and select "Open Project of Folder". The IDE opens the Maven project in the Projects window as a new NetBeans project, since the IDE knows how to interpret the Maven POM file:

Then right-click the project node and choose "Build with Dependencies".

Now another process starts up, pretty lengthy which makes sense considering how large GlassFish is, which can again be monitored in the Output window:

Finally, when everything is compiled, and half the internet is downloaded, you're ready to work on the GlassFish sources:

Note: The list of Maven projects comprising the GlassFish sources goes on quite a bit further beyond what's shown in the screenshot above.

Wednesday Aug 28, 2013

Beefed Up Code Completion in NetBeans IDE 7.4

When I call up code completion in all versions of NetBeans IDE, the Java Editor gives typed suggestions for completing the current statement:

This is called code completion. No surprises there.

However, if I invoke code completion a second time (i.e., press Ctrl-Space twice), a deeper level of suggestions is returned in NetBeans IDE 7.3.1, as well as in recent releases before that:

However, in NetBeans IDE 7.4, instead of the above, the code completion includes suggestions applicable to attributes from the current scope of variables, in the form of parameters for methods:

This is also known as "chained completion". In other words, when in NetBeans IDE 7.4 you invoke code completion a second time, the Java Editor will scan variables, fields and methods, which are visible from the context, and then suggest a chain that conforms to the relevant type.

More info about this can be found here:

Next, another excellent enhancement, this time by external contributor Benno Markiewicz. In 7.3.1, I try to use code completion here, because I'm interested to see whether any methods relating to property listening can be attached to my object:

No luck, as you can see. In 7.4, however, there's a new checkbox in the Options window, disabled by default because the underlying functionality is potentially slower and you'll get more results so is potentially confusing, so that explicit enablement means you know what you're getting yourself into, named "Subword completion", as you can see below:

And now, I get some very interesting and, more importantly, useful results, applicable to properties on my object:

More info about subword completion can be found here:

Tuesday Aug 27, 2013

PhoneGap for Java Developers

What I like about the PhoneGap concept is that you can write a mobile application in HTML, JavaScript, and CSS without needing to care where it will be deployed. But how about writing a native mobile application without needing to care about where it will be deployed?

And how can that even be possible, since by definition a native application is written in a language native to the mobile platform one is interested in, e.g., iOS or Android, for example. So, what you'd need to have is the possibility of writing the application in one language and then somehow converting it so that it can be run on the mobile platform of choice.

That's exactly the promise of Codename One, together with the (very popular) related Codename One NetBeans plugin. Program your application in Java and then have it converted to the mobile platform/s of choice:

Once you choose one of the "Send" menu items above, go to the build server page on, where you can pick up the build that's been created for you:

Interesting solution! The only thing is that it's a bit unclear, of course, what actually happens to my code to convert it to the mobile platform of my choice. Is this a problem, though? I.e., one needs to place a certain degree of trust in Codename One, especially when the application relates to data-sensitive or otherwise confidential software.

Anyway, I'll be taking the Codename One plugin for a ride a bit in the coming weeks, just to see what all the buzz (i.e., really lots of downloads for this plugin so far) is all about.

Monday Aug 26, 2013

Fixing Similar Code All In One Go Throughout All Applications

Recently I was showing someone how NetBeans IDE lets you fix missing @Override annotations:

Then the someone said: "Well, now that I have fixed this particular missing @Override annotation, it would be cool if I could immediately tell NetBeans to find all other instances of missing @Override annotations, throughout my application."

And, as luck would have it, all you need to do is click the right arrow key (as can be seen by the arrow in the hint above) and you'll see it expand to the following:

If you select the third or fourth items above, a dialog will open where you can set the scope (by default, the current file, but it could be all open projects, the current project, or the current package) for searching for instances of missing @Override annotations. In the third case, the missing @Override annotations will be found and listed, while in the fourth case you'll also be able to fix all those missing annotations simply by clicking a button and then everywhere within the selected scope the missing @Override annotation will be added: 

Pretty cool, since it makes sense that you'd want to find all other instances of the same problem once your attention has been caught by one of them.

Interested to know more generally what you, humble reader of this blog, think about the support for Java hints in NetBeans IDE? What do you like about it/them? (What's your favorite Java hint and why?) What could be improved? What's missing? 

Sunday Aug 25, 2013

Eclipse Formatter for NetBeans IDE (Part 1)

Several times I've been told that the only major blocker to considering NetBeans IDE as a viable alternative is that Java formatting rules have been defined in Eclipse and that those formatting rules cannot be imported into NetBeans IDE.

Well, Willie Scholtz from South Africa has solved this problem:

And I followed the instructions in his blog and I now have a plugin that provides the possibility to integrate an Eclipse XML formatting file into NetBeans IDE:

Here's how it works. Install the plugin into NetBeans IDE 7.3.1 (should also work in later versions but haven't tried that) and then go to the Options window and register your Eclipse formatting XML file:

That's it, you're done. Now, whenever you save a Java source file, the formatting rules defined in the XML file you registered above are applied. At the moment, no checks are done to see whether the XML file is a valid Eclipse formatting file. The assumption is that you've configured Java formatting rules in Eclipse, that you exported those rules, and that you therefore have an XML file containing all those rules. That XML file is the one that you should have registered above. No restarts or anything like that is needed. Immediately after you click OK above, the formatting rules in the XML file will be applied whenever you make a change in a file and click Save.

Regardless of whether this plugin is useful to you, do you want to help by trying it out? Take the following steps, in this order:

  1. Start up NetBeans IDE 7.3.1 with a fresh user directory. And then install the plugin into NetBeans IDE 7.3.1.

  2. In the New Project wizard, go to Java | Java Application and complete the wizard. Now you have a new Java SE project with a Java source file.

  3. Go to the Options window and register an XML file on disk, named "eclipse-demo.xml", with this content:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <profiles version="1">
        <profile kind="CodeFormatterProfile" name="eclipse-demo" version="1">

    When you click OK to exit the Options window, this message in the status bar (i.e., left corner of the IDE) tells you that you have set the Eclipse formatting file, if you don't see this, you have not succeeded in setting the file:

  4. Declare the following in the Java source file:
    public enum X { A,B,C,D,E,F}

    Save the file and now you should see this:

    public enum X {

Any feedback is very welcome.

Additional references:

Update 6 September 2013: See part2 here.

Update 31 October 2013: See part 3 here.

Friday Aug 23, 2013

JavaFX 8 DatePicker with Lambdas in NetBeans IDE 7.4

The JavaFX 8 API, which is bundled with JDK 8, contains a new UI control known as the DatePicker. The video below by Jim Weaver demonstrates how to use NetBeans IDE 7.4 Beta to create a JavaFX application from scratch that contains a DatePicker. It also touches on using Java lambda expressions to simplify event handling. In addition, the new date/time API is discussed, and the JFXtras CalendarPicker is demonstrated.

The blog post associated with this video is located in Jim Weaver's Rich-Client Java Blog at the following URL:

Thursday Aug 22, 2013

Setting Up the "sun-appserv-samples" Database

When you start up NetBeans IDE, you're automatically given a Java DB database named "sample", which unsurprisingly includes some sample data:

However, you have access to another database, should you need it, via utilities provided by GlassFish. Right-click the GlassFish node in the IDE and choose "View Domain Admin Console", as shown here:

Once the Admin Console has started up in your browser, navigate to Resources | JDBC | Derby Pool, as shown below:

Click the "Ping" button that you see above. Then, the database defined in the "Additional Properties" tab, shown below, will be created, automatically, i.e., during the process that's started when "Ping" is clicked. By default, as you can see below, that database is named "sun-appserv-samples".

In the IDE, then go to the Services window, and right-click "New Connection". Now you can register your new database, i.e., the one created above:

Here's what you need to set to specify after click Next above:

You now have your new database registered in the IDE:

However, a simpler approach, from a NetBeans IDE point of view (i.e., not everyone uses NetBeans IDE, so in those cases using the Admin Console for this purpose is useful) is to right-click the Java DB node in NetBeans IDE and choose "Create Database" and then create the database from there, within the IDE.

Wednesday Aug 21, 2013

More Expressive Navigator in NetBeans IDE 7.4

Interesting and cool that an HTML file in the NetBeans Navigator in NetBeans IDE 7.4 shows JavaScript and CSS content:

...while in 7.3.1, it didn't:

Tuesday Aug 20, 2013

Java Scrapbook for NetBeans IDE

In a couple of NetBeans discussions and issues, users are asking for a Java scrapbook feature:

I took Jesse Glick's Scrapbook feature, mentioned at the end of the issue above, included Java code templates, coloring, and other features, and have made it available as a plugin in the Plugin Portal:

After you install it in NetBeans IDE 7.3.1 or above, create a new Java project (Java SE, or EE, or whatever, so long as the project has a Java classpath). The feature lets you keep track of sample code snippets, which are stored in a scrapbook file in the 'private' folder of your NetBeans project and when you run them, after right-clicking in the editor, they are executed against the project's classpath.  

So, you first need to create a Java project, since the classpath from the project is used when you run the snippet:

Then the editor opens and you can use quite a few of the Java editing features, but not code completion, to write some snippets:

By default, i.e., if  you select nothing in the editor, when you right-click and choose "Run Snippet" everything in the editor is run. However, if you have something selected, e.g., the whole of line 7 above, then only that line will be run. In other words, you can run blocks of code.

Similar plugins, though they don't let you run code:

Interested to know how useful this feature is considered to be! Ultimately, maybe something to include in NetBeans IDE? 

Monday Aug 19, 2013

Yet Another NetBeans Platform Application: Oracle SQL Developer Data Modeler 4.0

Yup, there's another NetBeans Platform application in Oracle's software stable. And it is Oracle SQL Developer Data Modeler 4.0:

Interesting that one can create diagrams and then export them. Maybe someone should look at those export formats and see whether one or more of them could be imported into NetBeans IDE and then converted into Java classes, methods, and so forth. At least the CSV format looks promising.

The flexible window system, as with Oracle SQL Developer 4.0 and Oracle JDeveloper 12c, is the NetBeans Platform window system, made possible by the fact that Oracle SQL Developer Data Modeler 4.0 is now integrated into the NetBeans Platform too, as evidenced by the NetBeans artifacts that you'll find in the installation directory:

Sunday Aug 18, 2013

Lift, Scala, Maven, and NetBeans IDE

Once you've installed the Scala plugin into NetBeans IDE and taken it for a test drive as described yesterday, you're a couple of clicks away from using Lift in NetBeans IDE. Click to enlarge the image below, which shows the Scala editor, in the context of a Maven web project, together with the result shown in the embedded browser. As can be seen below, the Scala console is also integrated, thanks to the Scala plugin.

Best of all, since the application is deployed to GlassFish, a redeploy happens on save. That means I make a change, save, and then refresh the browser, whether embedded or external, to see the change. This, combined with everything else, makes NetBeans IDE a very productive environment for Lift development.

Even better than best of all is that NetBeans IDE 7.4 enables Maven projects to integrate with the browser, i.e., either the Chrome browser or the embedded browser. That means you'll be able to click in the browser and see where items are defined in the IDE, use the DOM Browser in the IDE to browse live through the items in your browser, and even change properties on the fly in the IDE and immediately see the changes live in the browser, as this screenshot shows:

And the two screenshots below show how I arrived at the above result, i.e., I indicated I want to create a project from a Maven archetype and then searched for "lift":

Interested to hear of others trying out this procedure, i.e., the steps described yesterday together with the above outline, very welcome to leave comments at the end of this blog entry.

In short, though, I believe that once the NetBeans Scala plugin is updated to be usable in NetBeans IDE 7.4, which is a task that only makes sense to do once NetBeans IDE 7.4 is actually released, NetBeans IDE will be paradise for Lift developers.

Saturday Aug 17, 2013

10 Steps to Happiness with Scala and NetBeans IDE

Took me about 20 minutes to figure out the procedure below, including downloading the related software. At the end, you'll have the samples from the Scala distribution up and running in NetBeans IDE. Click to enlarge the image below:

Let's get started.

  1. Get NetBeans IDE. Download NetBeans IDE 7.3.1, which is the latest official release of NetBeans IDE at the time of writing. If all you want to do is use Scala in NetBeans IDE, make sure to download the "Java SE" distribution, since that's the smallest distribution providing the basic toolset on top of which you will install the Scala plugin.

  2. Get Scala. Download Scala and set it up so that when you run Scala on the command line, it works. That's a nice way to check that you have downloaded and installed Scala correctly.

  3. Connect Scala to NetBeans IDE. Open the "etc/netbeans.conf" file, in the installation directory of NetBeans IDE, and use "-J-Dscala.home" in "netbeans_default_options" to point to your Scala installation. For example, on Ubuntu, my "netbeans_default_options" in "etc/netbeans.conf" is now as follows:
    netbeans_default_options="--laf Nimbus -J-Dscala.home=/home/geertjan/scala/scala-2.10.2 
    -J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-Dapple.laf.useScreenMenuBar=true -J-Dsun.java2d.noddraw=true 
  4. Install the NetBeans Scala Plugin. Start NetBeans IDE and go to Tools | Plugins and install all the Scala modules which, together, constitute the NetBeans Scala plugin:

  5. Verify Scala is Connected to NetBeans IDE. After installing all the modules shown above, go to Tools | Scala Platforms. Each of the tabs, "Classes", "Sources", and "Javadoc" should show some content, based on a combination of the Java platform and the Scala platform.

  6. Take a Look at the Project Templates. Go to the New Project wizard (Ctrl-Shift-N) and notice there are three new project templates in a new category appropriately named Scala:

  7. Import the Scala Samples into NetBeans IDE. Select "Scala Project with Existing Sources" and click Next. Name the new project "scala-samples" and place it anywhere you like on disk, e.g., in the NetBeans Projects folder:

    Click Next. Browse to the root folder of your Scala download, i.e., in my case, "/home/geertjan/scala/scala-2.10.2".

    Then click Next again. In the "Excludes" field, exclude all the folders that are not named "examples". That is, we're creating a new NetBeans project based on the "examples" folder in the Scala distribution, hence we don't want all the non-examples folders in our project.

    Click Finish and now you have a NetBeans Scala project consisting of all the samples in the Scala distribution:

  8. Fix Import Statements. Right-click and build the project and notice that there are some Scala packages that are incorrectly declared. I.e., the Duration class is in a different package than that which is declared in some of the examples, so use the error annotations and hints to correct those occurrences.

  9. Define Run Configurations. I noticed that individual files can't be run, i.e., no right-click and Run File. So go to the toolbar and create some run configurations:

    In each case, simply type the full path to the class you want to run:

  10. Run the Project. Finally, when you run the project, and you have a main class defined as shown in the previous step, you'll see the result in the Output window:

Seems to me that the NetBeans Scala plugin is very mature. Syntax coloring, code completion, etc. Nice.

Friday Aug 16, 2013

Yet Another NetBeans Platform Application: Oracle SQL Developer 4.0

I took a look at Oracle SQL Developer 4.0 today. Startup is really fast and a lot is familiar:

And the window system too, much more flexible than what SQL Developer used to have!

Here's the installation directory, i.e., including parts of NetBeans:

Very cool, just like JDeveloper 12c.

Thursday Aug 15, 2013

Receiving Tweets in the NetBeans IDE Notifications Window

NetBeans IDE 7.4 provides a Notifications window as a centralized mechanism for displaying all application-wide messages.

These messages are not related to specific projects or files, that's what the Action Items window is for. For example, if the IDE is taking a long time to do something, you'll get a message in the Notifications window inviting you to file an issue.

But how about using it as a Twitter Viewer as well? I'm on Twitter a lot and all I really care about are Tweets that relate to NetBeans IDE. So, below I have integrated Twitter4J and now, after the IDE's main window is showing, a Twitter search is done in the background every 10 seconds for tweets containing the text "netbeans", with the results automatically displayed in the Notifications window, because all calls to org.openide.awt.NotificationDisplayer cause, aside from a balloon message, an entry to be created in the Notifications window.

Click to enlarge the image. Handily, new Tweets in the list are marked in bold, until I select them, at which point they're no longer bold because I have read them. I have no need to actually write my tweets in the IDE, but I do find it handy to know when there's a Tweet out there that I might like to respond to. Then I click the link in the panel to the right of the list and the browser opens at the Tweet that I'd like to do something with.

This really helps my productivity significantly since I no longer need to go to the browser to search for "netbeans" on Twitter. Instead, every 10 seconds while I'm programming in the IDE, which is most of the day, I get new Tweets delivered directly into my IDE. And then I can decide what to do with them. Since all of them relate directly to NetBeans, this really enhances my workflow quite a lot.

The code:

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.HashSet;
import java.util.Set;
import org.openide.awt.HtmlBrowser.URLDisplayer;
import org.openide.awt.NotificationDisplayer;
import org.openide.awt.StatusDisplayer;
import org.openide.util.Exceptions;
import org.openide.util.ImageUtilities;
import org.openide.util.RequestProcessor;
import twitter4j.Query;
import twitter4j.QueryResult;
import twitter4j.Status;
import twitter4j.Twitter;
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;
import twitter4j.conf.ConfigurationBuilder;

public class OnShowingFindTweets implements Runnable {

    private static RequestProcessor RP;
    private final RequestProcessor.Task REFRESHER;
    private static int REFRESH_DELAY;
    private final Set<Status> statusHistory;

    public OnShowingFindTweets() {
        RP = new RequestProcessor(OnShowingFindTweets.class);
        REFRESHER = RP.create(this);
        REFRESH_DELAY = 10000;
        statusHistory = new HashSet<Status>();
    public void run() {
        StatusDisplayer.getDefault().setStatusText("Looking for more Tweets...");

    public void refreshTweets() {
        ConfigurationBuilder configBuilder = new ConfigurationBuilder();
        TwitterFactory tf = new TwitterFactory(;
        Twitter twitter = tf.getInstance();
        Query query = new Query("netbeans");
        QueryResult result;
        try {
            result =;
            for (final Status status : result.getTweets()) {
                if (!statusHistory.contains(status)) {
                    final String url = "" + 
                            status.getUser().getScreenName() + "/status/" + status.getId();
                            "@" + status.getUser().getScreenName() + ": " + status.getText(),
                            ImageUtilities.loadImageIcon("org/demo/icon.png", false),
                            //action listener:
                            new ActionListener() {
                                public void actionPerformed(ActionEvent e) {
                                    try {
                                        new URL(url));
                                    } catch (MalformedURLException eee) {
        } catch (TwitterException ex) {


On Twitter4J, the following proved very helpful:

Wednesday Aug 14, 2013

New Task Management in NetBeans IDE 7.4

Especially handy for enterprises with large bugtracking databases, NetBeans IDE 7.4, currently in its Beta release, introduces a new Task Management Window. The details are described here:

Prior to NetBeans IDE 7.4, though there was support for registering bug trackers, the overview of queries was poor, there were no access points for task management in general, and no categories. In contrast, below you can see that the results of my queries are displayed in a list, i.e., in the Task Management Window, from where I can categorize them:

I know I'll be fixing my issues much faster than before, now that they're integrated directly into my development environment. No excuse to avoid them now... 

Both Bugzilla and JIRA are supported out of the box. The Options window lets you configure the above window, e.g., how often the list should be automatically refreshed.

Also note that this is seen as part of a continuing process of enhancing the support for task management in NetBeans IDE. Features for scheduling tasks could be added in future releases, for example, as well as the co-ordination of tasks with other features of the IDE.

Tuesday Aug 13, 2013

Work with Multiple Large Apps Easily in NetBeans IDE 7.4

You're working on large projects, multiple projects, simultaneously. At some point you've got so many files open, you can't see the wood for the trees. Along comes NetBeans IDE 7.4, which assigns a common tab color for all files belonging to the same project:

A quick glance is all that's needed to reorientate yourself to identify which file belongs to the work you're currently doing. Moreover, as you can see above, the small drop-down for navigating between files can be sorted based on the projects they belong to.

And this is especially handy when you're working on multi-modular NetBeans Platform applications, since all the files belonging to the same module can now have the same tab color:

All this is possible thanks to two new checkboxes in the Windows tab of the Miscellaneous category in the Options window:

Above, you can see I have selected "Same background color for files from the same project", as well as "Sort opened document list by project".

Several other items in the above screenshot are new in NetBeans IDE 7.4, e.g., the look and feel drop-down, as discussed in yesterday's blog entry.

Monday Aug 12, 2013

7.4 vs. 7.3.1: Configuring the NetBeans Window System

When you're creating an application on the NetBeans Platform, you automatically have access to an extensible Options Window as a centralized location for customizing various parts of the application. A default subtab of that Options Window is dedicated to configuration settings for the Window System of the application.

Here's what it looks like in NetBeans Platform 7.3.1:

And this is what it looks like in NetBeans Platform 7.4:

See "Show parent folder in tab title" and "Show full file path" below, together with tab placement "bottom" and maximum row count 2:

Of course, I didn't type a single line of code to create the application you see above. Aside from the NetBeans Platform modules automatically included by the "NetBeans Platform Application" template, I included the "ide/User Utilities" module to include the "File | Open File" menu item and the "ide/Image" module to include the NetBeans Image Editor and the code for recognizing and loading image files.

Note: The enhancements, i.e., the differences between the first two screenshots of the Options window, not including the Look and Feel drop-down, come from a new module "org.netbeans.core.multitabs". If you exclude "platform/Multi-tabs" in the Project Properties dialog of the application, you'll be excluding the enhancements, which includes the scroll buttons:

Protein Structure Analysis on the NetBeans Platform

Last week I answered a question asked by Vilém Šustr from the CAVER team. CAVER is a tool for the analysis and visualization of tunnels and channels in protein structures. And today he sent some pretty pictures, together with these words:

We chose the NetBeans Platform a few years ago and our software grew with it. The software is quite specific, so we us the platform in our own way sometimes. But it saves us a lot of work and we like it a lot! Recently we've done some finetuning to CAVER Analyst and it is going to be released within a few weeks.

Here are the pictures he sent, click the first two to enlarge them. 


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.


« August 2013 »