Using JShell in NetBeans

With Java 9 comes JShell, the first official Java Read-Eval-Print-Loop (REPL). The Takipi blog has a nice article out, just in case you don’t know nothing about it. Read it here: Java 9 Early Access: A Hands-on Session with JShell – The Java REPL.

I’m gonna show you today a short screen cast using the current nightly build from the free and Open Source IDE NetBeans. NetBeans allows to run JShell not only with JDK 8 but also agains an opened Maven project, containing all the dependencies from your POM file and the classes of your project.

The first part is a recap what JShell REPL is all about. In the second part, I’m gonna use my DOAG 2016 project. The project is a database centric project using jOOQ for creating database queries.

I’m gonna open up a JDBC connection to a local Oracle Database and execute some queries, from really simple ones to the ones I used in this talk:

What is it good for? In this case I can design complex database queries, try them out, having all the NetBeans features and tools at hand without going through a save / compile / reload whatever cycle. The NetBeans nightly has a lot of rough edges, sure, but you see the potential here.

I also tried starting up Springs application context, but that didn’t work for me yet. That would also incredible useful, especially in regard to generated Spring Data repositories.

| Comments (0) »


Java: 2016 recap

As last year I’m gonna write a short recap here. In global life, 2016 wasn’t a good year, in my private and work life however, 2016 was the best year in a long time. Java activity started early 2016, first with an Euregio JUG event having Bert-Jan in Aachen, NetBeans day in Utrecht and Java Land in Brühl. Also in the pictures Toni, Geertjan, René, Rainer, Josh and Adam:

I’m inclined to say that this:

changed everything again. I’ve been visiting conferences now for years and they started to become really awesome after having some great friends in the community but I never spoke. I changed that for good in May at Spring I/O and it was a great event. Thank you Sergi for putting your trust in me and René Glen from above for giving me great feedback for my first talk!

Michael^2, Geertjan

I continued speaking in a small NetBeans event in cologne and spoke about NetBeans, Maven and Spring Boot, meeting Michael Müller, Geertjan Wielenga and Stephan Knitelius.

Speaking of NetBeans: My friend Geertjan from Oracle, seen in disguise in the picture below, proposed me as member of the NetBeans dream team. What an honor!

Roughly at the same time, Red Hats Vlad Mihalcea, Developer Advocate for Hibernate, not only author of FlexyPool but also the other the definitive guide to all things persistence with Java named High-Performance Java Persistence started a series of great interviews on and invited me to join that list. Thank you again, Vlad!

In November I spoke again, at W-JAX 2016 and also at DOAG Konferenz und Ausstellung. It was an honor to be there:

Throughout those days these with Lukas, Henning, Axel, Niko, Christian, Matthias, Michael, Wolfgang, Oliver and Kai:

Even if I really get nervous all the time, speaking at this conferences was a valuable experience and I’ll try to continue that, starting early in 2017 at the newly founded Spring Meetup Munich together with Michael Plöd from InnoQ. If you think a talk about anything Spring and Databases or how to work with them using NetBeans would fit your JUG, please, drop me a line.

I wrote a lot this year and could publish several articles on German and English JAXenter which I collected on my about page. Apart from that stuff I wrote 35 blog posts this year here… Many of them got featured on the Spring blog, the jOOQ community page, in both Eugens and Thorbens Java Web weekly newsletters. Thank you Thorben, Eugen, Lukas and Josh.

The first book I ever wrote sold over 700 times which surprised me a lot. Have a look, Arc42 by example.

I managed to organize 6 events at our Euregio JUG, having Bert Jan Schrijver, Johan Vos, Max Wielsch, Manuel Mauky, Gernot Starke, Geoffrey De Smet, Carola Lilienthal and Mark Paluch:

Running this JUG is incredible rewarding: Not only I learn a lot of stuff, but can meet and talk with awesome people who love to share their knowledge and I’m looking forward to continue this in 2017. If you want to visit Aachen, please contact me: and we arrange something!

with Mark Heckler

Also, as a visitor: Go to a JUG at your place. In Germany, there’s one easily reachable from nearly everywhere in Germany, see the iJUG website. There’s also a curated map of JUGs worldwide, see Java User Group & events. It’s really easy to learn first hand knowledge from the experts or just have drink and talk. Invite others and convince them that those meet ups are great places. Smaller conferences like J-Fall, organized by the nl.JUG are also a day worth spent!

with Bruno Borges

Oh and by the way: In my last years Christmas holiday, I wrote the site for the Euregio JUG using Spring Boot and some other tools and it has been running on a sponsored Pivotal CF account for a year now. Really easy to deploy, using marketplace services like various databases, Elasticsearch and more is a no-brainer thanks to automatic reconfiguration of Spring Boot. Highly recommended!

The community we have in “Java land” is one of the most important assets, despite having sometimes a heated discussion over a few topics (I *have* to create an insult con some time), but that’s fine… The selfies in this post are my tribute to this community. You rock!

Also, a big thank you to my company ENERKO INFORMATIK, making it possible not only work on the stuff I like but also running a JUG amongst other stuff.

But most important, thank you to @tinasimons, wife, mother, developer and one of the hardest working persons I know and the one person I can always rely on. I’m so glad that she supports the ideas (and there are quite some right now) I have for next year. Here are just 11 years from 16 we have spent together in two pictures:

| Comments (2) »


Oracle JET: JavaScript components for mere mortals?

The final post in this series is about adding a front end to the analytic queries created with jOOQ and published through Spring Boot / MVC throughout the previous posts:

  1. Database centric applications with Spring Boot and jOOQ
  2. Create a Oracle Database Docker container for your Spring Boot + jOOQ application
  3. Take control of your development databases evolution
  4. An HTTP api for analytic queries

Deciding on a frontend technology for web applications

As much as I still like server side rendered HTML, there is some great stuff out there ready to use. I have written about creating a Anguluar 1 front end for a Spring Boot app nearly two years, so I had to research current options.

There’s quite a few buzz around

Alexander Casall did a very good presentation at W-JAX last week which of those techniques is the right choice for you. They both do have very different approaches. ReactJS focuses more on a modern programming paradigm where Angular 2 provides a more complete solution in terms of how one structures an applications, provides dependency injection and so on (On my todo list is an upgrade to above posts, where I will showcase upcoming Spring Framework 5 / Boot 2 with Angular 2).

What both Angular 2 and ReactJS are missing for the use case developed during in this series however, providing fast access to a lot of business relevant data, is a set of curated UI components, especially collections and data visualizations. I know, there is great stuff out there, but all must be carefully selected to work together.

This is where Oracle JET comes in. To quote Oracle:

“It’s a collection of open source JavaScript libraries along with a set of Oracle contributed JavaScript libraries that make it as simple and efficient as possible to build applications […]”

The sales pitch ends up in “consuming and interacting with Oracle products”. Well, you can do that, too.

I think more like a curated set of well proven open source modules of Oracle JET. It basically provides

  • RequireJS for managing used modules inside your scripts
  • Knockout. for providing two-way bindings between models and views
  • jQuery
  • jQuery UI which is the foundation for the great list of UI components included

Getting started with OracleJET

A new Oracle JET application can be created with a Yeoman generator which comes in various flavors: A basic starter which provides only the basic project structure and an empty page, a nav bar starter that has a responsive side bar and a starter that already provides hooks for going native through Cordova.

I personally prefer NetBeans 8.2 for those kind of tasks:

Geertjan has a nice article up, that explains in detail whats new in NetBeans 8.2 for Oracle Jet:

You have several options to use an application generated like that. One is using the provided grunt tasks like grunt build and grunt serve and especially later, when going to production, grunt build:release which does all the black magic of minimizing and optimizing your views and models. Again, you can use NetBeans for those tasks:

I do have a second Oracle JET based application up and running which is the admin backend of my user groups site, available here. This application is build as described above and then deployed to Pivotal CF using the static build pack.

The demo

Checkout the full source michael-simons/DOAG2016 here!

In the demo for DOAG Konferenz und Ausstellung I have chosen a different approach. Consider you want to deploy your analytic query together with an easy to use frontend: All static resources you put into src/main/resources/static are delivered “as is” by the embedded application container of your Spring Boot application, Tomcat being the default as of writing. This is what I did in #8158f5a (the commit is really huge, containing all the small JS files…). The single page application (SPA) is prefixed with “app”, so that I can display my carefully crafted Spring Boot loves jOOQ banner on the entry page before 😉

Note This works quite well, but I wouldn’t want to deliver the huge bulk of those JS, CSS and HTML files this way into production! I wanted to have a single, deployable artifact with a build process I can demonstrate in 90 minutes, even to non JavaScript developers. In production make sure you use the above grunt build:release target before this stuff reaches your customers browser!

Oracle JET uses Knockout for data binding, which is a prominent representative of a Model-View-View Model (MVV) framework.

A model that makes use of the query that provides the cumulative plays of artists by day from the previous post may look like this, see viewModels/artists.js:

define(['ojs/ojcore', 'knockout', 'jquery', 'moment', 'ojs/ojselectcombobox', 'ojs/ojchart', 'ojs/ojdatetimepicker'],
        function (oj, ko, $, moment) {
            function artistsContentViewModel() {
                var self = this;
                // The array containing all artists from api
                // Use the ojCombobox to implement server side filtering instead
                // of my brute force approach getting all artists
                self.allArtists = ko.observableArray([]);
                // We need this to store and get the selected artists...
                self.selectedArtists = ko.observableArray([]);
                // Load the artists data
                ko.computed(function () {
                        url: "/api/artists",
                        type: 'GET',
                        dataType: 'json',
                        success: function (data, textStatus, jqXHR) {
                            for (var i = 0, len = data.records.length; i < len; i++) {
                                self.allArtists.push({value: data.records[i][0], label: data.records[i][1]});
                }, this);
                self.fromValue = ko.observable('2016-01-01');
                self.toValue = ko.observable('2016-03-31');
                self.areaSeriesValue = ko.observableArray([]);
                self.areaGroupsValue = ko.observableArray([]);
                self.dataCursorValue = ko.observable('off');
                self.topNTracksSeriesValue = ko.observableArray([]);
                self.topNAlbumsSeriesValue = ko.observableArray([]);
                self.chartLabel = function (dataContext) {
                    return dataContext.series;
                var updateCharts = function () {
                    if (self.selectedArtists().length === 0) {
                    var dateRange = {
                        from: self.fromValue(),
                        to: self.toValue()
                        url: "/api/artists/" + self.selectedArtists().join() + "/cumulativePlays",
                        type: 'GET',
                        data: dateRange,
                        dataType: 'json',
                        success: function (data, textStatus, jqXHR) {
                            if (data.records.length === 0) {
                            // Need the artists labels for the series
                            var artists = self.allArtists().filter(function (elem) {
                                return self.selectedArtists.indexOf(elem.value) >= 0;
                            }).map(function (elem) {
                                return elem.label;
                            // Make it nice and compute continous days
                            var firstDay = moment(data.records[0][0]);
                            var lastDay = moment(data.records[data.records.length - 1][0]);
                            var days = [];
                            while (firstDay.isSameOrBefore(lastDay)) {
                                firstDay.add(1, 'd');
                            // Create groups and series from array of records                            
                            // This groups the records by day
                            var hlp = data.records.reduce(function (acc, cur) {
                                var key = moment(cur[0]).toDate();
                                if (acc[key]) {
                                    acc[key][cur[1]] = cur[2];
                                } else {
                                    acc[key] = {};
                                    $.each(artists, function (i, val) {
                                        acc[key][val] = val === cur[1] ? cur[2] : null;
                                return acc;
                            }, {});
                            // This collects the items by artists
                            var series = (label) {
                                var data = [];
                                var prev = 0;
                                $.each(days, function (i, value) {
                                    var cur = hlp[value] && hlp[value][label] || prev;
                                    prev = cur;
                                return {name: label, items: data};
                                url: "/api/artists/" + self.selectedArtists().join() + "/topNTracks",
                                type: 'GET',
                                data: dateRange
                                url: "/api/artists/" + self.selectedArtists().join() + "/topNAlbums",
                                type: 'GET',
                                data: dateRange
                   .done(function (tracks, albums) {
                        var hlp = [];
                        for (var i = 0, len = tracks[0].records.length; i < len; i++) {
                            hlp.push({name: tracks[0].records[i][1], items: [tracks[0].records[i][2]]});
                        hlp = [];
                        for (var i = 0, len = albums[0].records.length; i < len; i++) {
                            hlp.push({name: albums[0].records[i][0], items: [albums[0].records[i][1]]});
                self.optionChanged = function (event, data) {
                    if ("value" !== data.option) {
            return new artistsContentViewModel();

Notice in the first line how you import Oracle JET modules by the means of RequireJS. The defined function than provides a nested function (artistsContentViewModel()) that creates the actual view model. The view model than is passed to the view.

Interesting stuff to see are the ko.observable which are the data bindings. In this demo I make every HTTP call through the jQuery api. There are probably better ways for tables, lists and such, have a look at those scripts, they use the oj.Collection api for the cool table component to achieve the same without the dirty details.

Coming back to my example. The model fields areaSeriesValue and areaGroupsValue go directly into a snippet that I basically copy and pasted from Line with Area Chart component:

<h2>Cumulative plays per artist and day</h2>
<div id='chart-container'>
    <div id="lineAreaChart" style="max-width:1024px;width:100%;height:320px;" data-bind="ojComponent: {
        component: 'ojChart', 
        type: 'lineWithArea', 
        series: areaSeriesValue, 
        groups: areaGroupsValue, 
        timeAxisType: 'enabled',
        animationOnDisplay: 'on',
        animationOnDataChange: 'on',            
        stack: 'on',             
        hoverBehavior: 'dim',
        zoomAndScroll: 'live',
        overview: {rendered: 'off'},
        dataCursor: dataCursorValue

This may not be fancy, but it does several things pretty well: It’s accessible, fully translated and easy understandable on the user side and easy enough to implement on developer side.

The cookbook

The Cookbook is really valuable. It presents all the components in great detail, the links to the api are up to date and it even gives you hints on where and when to use a certain type of visualization. With it at hand I created the frontend for DOAG2016 in about three days:


If you want to be always bleeding edge – which I can fully understand – don’t go near Oracle JET. You won’t like it. If you have to suit a projects needs, presenting lots of data, often visualized and don’t have time or the will to figure all the ways you can setup a JavaScript application yourself, give OracleJET a try.

I find the basic architecture well thought through, highly extensible (I did it with several Spring collections apis and more) and excellent documented.

One of the best things is, from a Java developers perspective actually, is the fact, that it doesn’t want to hide JavaScript and HTML code and fragments behind Java code, which brings in too much abstraction according to my experience. You can achieve a lot by using for example GWT based stuff, but the moment you have to create your own components, you basically have to learn the interns of the chosen framework, JavaScript, HTML and CSS… The later 3 are somewhat standards, which is why I like to have them in my toolbelt anyway.


In 5 posts I walked you from setting up a skeleton Spring Boot project that provides a database connection or connection pool and a jOOQ context to creating an Oracle Database inside a container for developing and integration purposes to advanced analytic queries and in the end, showed one way to provide a UI. After 5 posts we end with a decent looking, database centric but not database dependent web applications.

In all steps I opted for the tools that make my life as a developer easier, facilitate the features I already payed for and help my customer to achieve their business goals.

There are several possible deployment scenarios: Run the application on Pivotal CF, get yourself a PostgreSQL database from the marketplace. You just have to push it. Put your frontend on some CDN. Or also on CF with the static build pack.

If you need an Oracle database, maybe Amazon RDS is the right choice for you. It doesn’t take much effort to run a Spring Boot application on Amazon EC2.

Do you prefer getting your Oracle Database right from the vendor? I once was in a talk by both Bruno and Josh who deployed a Spring Boot application to the Oracle Cloud.

Regarding your database: I still love coding in Java. Even more so with Java 8. But why not using parts of all the awesome analytic functions my database, for example PostgreSQL and Oracle, offer? Both support fantastic spatial queries, XML and JSON. Maybe you already have relational database knowledge in your company: Use it! Get rid of bad practices putting everything into the database, but use it for what it was designed for. Don’t reinvent the wheel.

Last but not least: If you have the time and ambition, try out new features (not only in the front end). Implement stuff yourself. It’s fine. Learn. But if you have a project goal, maybe a prepackaged structure for a client side web application is enough and something like OracleJET is of value to you as well.

Thank you so much for your attention and reading so far. The demo project and the talk have been in the making for about 6 months. We actually use most of it inside new projects (not the OracleJET part yet) and it was time well invested researching that stack.

| Comments (0) »


An HTTP api for analytic queries

This post has been featured on This Week in Spring – November 8, 2016 and I’m so happy to be referred as “friend of the Spring community” 🙂

So, you have read through the previous parts of this series (1, 2 and 3) and you now have a Spring Boot project with jOOQ enabled, an Oracle Database with a simple schema containing musical data. What can you do with it?


  1. An introductory example
  2. Window functions with jOOQ
  3. Common table expressions, window functions and Java expressions combined
  4. Summary and use cases

In the previous post I had a simple select, getting all artists from my library ordered by name. For queries like that I wouldn’t bother investigating into jOOQ. I have written extensively about my use of Hibernate and summarized my thoughts in this interview. In short: You can come very far with JPA / Hibernate, you can even create portable JPQL queries that support some analytics, as Thorben shows. Thorben also has a nice little tool that helps deciding wether JPA / Hibernate is the right tool for the job, checkout it out: Should you use JPA for your next project?

Imagine the following use cases based on this schema:

  • I want a list of top n albums by a list of artists ordered by play count
  • I want a list of artists and how many times I played a track by them cumulative by day
  • Given a specific months, I want a top n list of tracks played in this month ordered by play count and also including the change in result to the previous month

You can try all examples yourself by cloning this repository: and running those steps:

./mvnw docker:start
./mvnw clean package
./mvnw spring-boot:run

Please read through the links at the top of this post to grok each step.

Read the complete article »

| Comments (4) »