Skip to main content

JavaOne for the Impatient

Posted by cayhorstmann on September 26, 2013 at 4:09 PM PDT

Here are my impressions from the 18th Java One. Java SE 8 is around the corner, Java EE 7 was just released, and both are a joy to use. NetBeans 7.4 is awesome. And yet, people were strangely blasé at the conference. I still remember how much excitement there was at Java One when Java was in its infancy, and the promises greatly exceeded the reality. (Do you remember Jini? Or the original Java EE?) Nowadays, that excitement is lavished on other technologies whose promises exceed the reality, and Java has grown up.

Apparently people do remember the original Java EE. Not the promise, but the reality. I am amazed how many people still think that Java EE is unbearably cumbersome, and to what lengths they go to avoid it. My favorite presentation of the conference was Adam Bien’s “ Lean and Opinionated Java EE 7 Applications”. He described pretty much what I have found myself doing: Use JAX-RS with stateless beans, don’t use ancient design patterns (DAO, DTO), don’t use Apache Commons when you can use a standard library, focus on the business logic and use the standard EE mechanisms for plumbing. It works for me, but the fact that it works for his customers is a lot more meaningful. He is a funny guy too (for a German at least...) Check him out if you get a chance.

As in the previous five Java Ones, there was much talk about JavaFX. I found it interesting that JavaFX runs so well on the Raspberry Pi, which has the horsepower of an Intel CPU from about 15 years ago. But its GPU is quite good, and JavaFX knows how to work with a GPU much better than Swing did. Oracle has publicly stated that Swing is in maintenance mode, so desktop developers (yes, there still are some left) were hungry for advice on how to transition their apps. Unfortunately, there doesn’t seem to be a silver bullet.

There was a lot of interest in the Java 8 features—all the talks about lambdas were packed. But I sensed more curiosity than excitement, which surprised me a bit since this is easily the biggest Java language change since, well, since Java 1.0. Java 8 is on track for early 2014, with regular snapshots that you can, and should, try out. I have used them without any problems for some time now, as I am writing Java 8 for the Really Impatient (which should be out in a few weeks). I guess we have been waiting for it so long that the excitement has dissipated.

What is my favorite Java 8 feature, other than lambdas and streams? Now, when you keep a ConcurrentHashMap of counters, you can increment the counter as

map.merge(key, 1, Integer::sum);

If the key isn't present, it is put into the map with a value of 1. Otherwise, it is replaced with 1 + the old value. And yes, it’s threadsafe. (Try doing that in Java 7. The only safe way I know uses AtomicInteger.)

Ok, that’s not fair—that code actually uses lambdas since Integer::sum is (x, y) -> x + y. So, my favorite feature that doesn’t use lambdas is the new Date/Time API. Call

ZonedDateTime nextMeeting = meeting.plus(Period.ofDays(7));

If meeting falls on Monday at 10 am, then nextMeeting is 10 am a week later, even if there was a daylight savings time change. That API is a joy to use and, yes, it too is threadsafe. In this example, the plus method is immutable.

My favorite Java tool of the show is NetBeans 7.4. The HTML 5/JavaScript implementation is awesome. You write your client code in JavaScript, your server code in Java EE, with autocompletion in both, click on debug, set breakpoints in the client or server, and it all works. Without installing any plugins. Without hours of configuration. Check it out here!

For me, the most fun presentation was the Raspberry Pi hands-on lab. They didn’t have enough devices, so we had to work with a lab mate. This is something I always do with my students since I figure that four eyes see more than two. It has been over thirty years that I had touched any hardware other than a PC, and I had never done any embedded programming, so those extra eyes were great. Our momentous achievement? We made the green light blink, using Java.

And the winner in the “wild and crazy” category is “The Chuck Norris Experiment: Running Java in Any Browser Without a Plug-in”. Anton Epple and Jaroslav Tulach (one of the founders of NetBeans) showed off bck2brwser, a strange and ambitious project to bring Java back into the browser. (There is no question that Java in the browser is effectively dead, except for legacy applications in corporate intranets. Multiple Oracle employees told me that nobody should develop new applets or WebStart applications.) Jaroslav wrote a Java virtual machine in JavaScript. You write your code in (a rather stringent subset of) Java and compile it to a JAR. His JavaScript code unpacks and executes it. Today, you can access the DOM and write games with Canvas. Tomorrow, perhaps the sky will be the limit. I hope it works out.

Comments

Using J2EE for website design or website developing is the ...

Using J2EE for website design or website developing is the best thing, A website made in this technology is fully flexible to run in all environments.
Responsive WordPress Website Theme

Regarding J2EE, the main problem is that what happens in the ...

Regarding J2EE, the main problem is that what happens in the real world is a bit different.

We still get consulting projects for J2EE 5, so whatever gets promoted as the latest and greatest is far away from our reality.