Posts Tagged Java

Better Type Inference in Java 8 Generics

Java 7 gave us the diamond operator:

  Map<String, String> dict = new HashMap<>();

The code above doesn’t duplicate the type parameters unnecessarily as it made perfect sense to extend type inference to instantiation. Now Java 8 pushes type inference a little further. Read the rest of this entry »

, , ,

Leave a comment

Java 8 Lambda Expressions Capture Values, Not Variables

Before Java 8, when we needed to use a local variable inside an anonymous inner class, the local variable had to be declared final:

public class ValueCaptureAnon {
  public static void main(String[] args) {
    String name = "Yagiz"; //Compile error in Java 7...

    Runnable runnable = new Runnable() {
      public void run() {
        System.out.println("Name is " + name);

Read the rest of this entry »

, , , ,


Building a RESTful Service Layer with JAX-RS, RESTEasy and Spring Framework

Just like many of you, we’ve been developing RESTful services for a while. We’ve used various frameworks in .NET and in Java, in large systems as well as on the server-side of our mobile apps. Unless there’s a good reason not to do so, REST is our preferred approach in building a service layer. Recently we’ve had a series of discussions about different approaches in building a RESTful service layer and I decided to outline one of the ways to do it using RESTEasy, Jackson, JSON and Spring Framework on the Java platform.

Read the rest of this entry »

, , , , , , , ,

Leave a comment

Showing Live Templates in Code Completion in IntelliJ IDEA

IntelliJ’s Live Templates are great help while one’s in the flow of development. You probably know a few by heart however it’s not easy, nor practical, to remember all the shortcuts. Wouldn’t it be nice to have them shown in the code completion pop-up?

Live Templates shown in the Code Completion pop-up

Go to “Help -> Find Action…”

Screen Shot 2013-12-31 at 14.05.37

Ensure that “Include non-menu actions” are checked. Search for “registry” and select “Registry”.

Screen Shot 2013-12-31 at 14.07.11

Find “” setting and enable it.

IntelliJ IDEA - Registry window

And voilà!

Happy New Year!

, , , ,

Leave a comment

JavaOne 2012 – Day 3

For me, finding time to blog in between sessions is almost impossible in JavaOne. Going back and forth between different hotels and trying to be in the room early enough to secure a nice seat are time consuming. And when you factor in the fact that the BOF (Birds of a Feather) sessions may end as late as 21:15, I’m not left with many viable options for blogging. Normally I’m a night owl. I can work well and be pretty productive late at night. However, this year I’m trying something new. I’m waking up at 5 AM to get some work done early in the morning.

When I blog about a day’s sessions, ideally I try to select a few sessions, the most interesting ones. But sometimes there are so many good sessions that it becomes really difficult to short-list them. Wednesday (javaOneDays[3]) was such a day when three of my Top 5 sessions took place. As an attendee it is a wonderful thing. However as a blogger it makes life harder. Read the rest of this entry »

, , , , , , , , , ,


JavaOne 2012 – Day 2

San Francisco is a busy city. Even though I wake up very early, the traffic and the noise outside suggest that this city never sleeps. But I’m sure most of the JavaOne attendees were sleeping at 5AM when I woke up to finish yesterday’s blog post. Anyway… Let’s get started. In today’s article I’m going to write about 4 of the sessions that I attended during Days[2] of JavaOne.

NoSQL Morning

JavaOne Day 2 started with two interesting NoSQL sessions. Read the rest of this entry »

, , , , , , , ,

Leave a comment

JavaOne 2012 – Day 1

JavaOne 2012

Unfortunately, as I feared, this first day of JavaOne started very early for me. I woke up at 4AM and I decided not to fight it. It gave me time to do a bit of work and write yesterday’s blog entry.

Atomic Data Structures

I left my hotel at 8 and walked 3 blocks that separated it from Hilton where my first session was taking place. It is important to pick a good session to start the week. I thought I did a good job in pre-enrolling in “How do atomic data structures work?” but unfortunately it didn’t live up to my expectations. It was obvious that the presenter knew his topic very well and this was his area of expertise however he gave the impression that he was nervous. Consequently, his talk was not well structured, his thoughts wandered and his jokes failed to revive the audience. Read the rest of this entry »

, , , , , , , ,

Leave a comment

JavaOne 2012 – Day 0

It is a long trip. A very long one. Even though I never forget this fact before the travelling to San Francisco, the reality sinks in during the journey. My knowledge counter reset after this reality check: 19 hours from home to the hotel. I’m not even going to complain about the jet lag. I’m here to write about JavaOne after all… wide awake at 4AM. So, let’s get started.

Every year there is one or a few dominating themes in JavaOne. You get a feel for it just by looking at the conference schedule during your pre-enrolment. If you check the same calender just before the first day of JavaOne, you can see which sessions are popular, too popular actually, and full. I even noticed a few talks whose waiting list was in the order of 200. So, without setting foot in Moscone Center and talking to fellow attendees one can get a fair impression about what are the main themes of the year.

There is definitely a concentration around Cloud-related sessions and also HTML5-related responsive Web technology sessions. But I think Cloud is the term we are going to hear most often in this year’s JavaOne. So, it doesn’t come as a surprise that Larry Ellison, CEO and co-founder of Oracle, introduced Oracle 12c to thousands of conference attendees at Moscone Center today. What does “c” stand for? You guessed it right: Cloud. One of the main design goals of Oracle 12c was Cloud computing deployments. Cloud is now at the heart of Oracle. They put the emphasis on the Private Cloud with their Exadata and/or Exalogic servers.

Again, it is very disappointing not to have any talk on Android. If there’s someone out there listening (or reading) this is me complaining about it. Android is Java’s only viable mobile platform. You keep talking about developers, community, teamwork, etc. Prove that these are not stories told just to motivate developers and companies in order to generate more revenue. Prove that you really care about what the community wants. Put your greed and differences aside for once and do what is right for the developers.

JavaOne 2012 - Technical Keynote Speech

JavaOne 2012 – Technical Keynote Speech

This year the format of the Technical Keynote Speech was somewhat different. There weren’t many short technology demos, which was probably a good thing. Instead, the JavaFX team has developed a Schedule Builder/Viewer application and it was the main application used in various demos. I think this is a better approach. It also serves a purpose and the attendees can use it during the conference to get a feel for it.

The Conference Schedule app was pretty slick and responsive. They ran it firstly on a Windows laptop. And then on a Mac. To be honest I couldn’t see any difference. I’m curious about its UI, and I’m going to look at it in detail if I can find an opportunity because some sections had a very iOS-like look and feel. From such a demo one can understand that JavaFX has come a long way. I especially liked  to hear about practical features such as being able to produce native code so that a JavaFX application can be submitted to Apple MacStore for instance.

A talk about Project Lambda was next. I’m not a huge fan of lambda expressions. I’ll probably use them but I have the feeling that they add more complexity and diminish the readability of the code. But I am going to hold on to refrain from having a strong opinion until I get a chance to use lambda expressions on real living, breathing code.

There was a brief mention of Java 8’s Default Methods. I like the idea. A very similar concept exists in Objective-C and being able to augment standard interfaces and provide default implementations come in handy.

Then they ran the same Conference Schedule application on a touchscreen kiosk (supporting multi-touch gestures) and on an impressive Raspberry Pi. Raspberry Pi is a nice little Linux box that you can get for $25. I’m not kidding. Go and have a look. Or as they advertise: “Take a byte!”

Then followed a short section about Project Jigsaw, explaining why it is now part of Java 9 and not as previously announced Java 8, and about the new Compact Profiles. The Compact Profiles specification defines three subset profiles for the Java Runtime Environment. Currently the entire JRE takes up about 52MB. The proposed profiles will take up 10MB, 17MB and 24MB, each level allowing a more feature-complete runtime. However, it looks like the minimalistic profile will allow things like running a Web server, for instance.

The second part of the keynote speech was about Java Enterprise Edition 7. Java EE 7 comes with increased productivity. It encompasses new and/or improved specifications such as:

  • A new batch API (Batch Applications For The Java Platform 1.0 – JSR 352),
  • A new JSON API (Java API For JSON Processing (JSON-P) – JSR 353),
  • A new WebSocket API (Java API For WebSocket 1.0 – JSR 356),
  • Java Temporary Caching API 1.0 (using annotations such as @CachePut, @CacheKeyParam, @CacheValue),
  • Bean Validation 1.1 (using annotations such as @NotNull, @Max(“10″), @Future),
  • JMS 2.0 (less verbose, reduced boilerplate code, resource injection, AutoCloseable support, etc)
  • JAX-RS 2.0 (client API, message filters and entity interceptors, etc)
  • THML5 support (HTML5 Forms, etc)

The keynote speech, a long one, ended at around 8PM, with the mention and demos of Project Avatar and Project Easel.

All in all, it looks like it is going to be an interesting week in JavaOne. Talk to you tomorrow.

, , , , , , , , , , , ,

Leave a comment

JavaOne 2010 – Day 2

Another morning but the same ritual: Getting ready, a short walk to Hilton San Francisco, silencing the grumbling stomach with a carb-packed breakfast and a cup of coffee for the morning pleasure. All this before joining the thousands of techies to attend the morning’s first session kicking off at 8am.

Read the rest of this entry »

, , , , , , , , ,


JavaOne 2010 – Day 1

JavaOne’s first official day started on a beautiful sunny morning, not that I could enjoy the sun very long. I was feeling jet lagged and, awake since 5am, I was ravenous by the time I entered Hilton. The good thing about this venue is that there’s always a Starbucks in proximity. There’s even one in Hilton. First things first, I got myself a cup of coffee and something to eat. The day started with the first sip from my decaf americano.

Read the rest of this entry »

, , , , , , , , ,

Leave a comment


Get every new post delivered to your Inbox.