Java Lobby Announcements

Subscribe to Java Lobby Announcements feed
Recent posts in Java on
Updated: 8 hours 14 min ago

Coming Soon: Scala Days 2016 NYC

Fri, 2016-04-15 08:01
Scala Days 2016 Schedule has been announced!


Beyond Shuffling: Scaling Apache Spark
by Holden Karau @holdenkarau

Categories: Java

Redis vs. Hazelcast – Radargun Puts Them to a Challenge

Thu, 2016-04-14 16:54

Since the initial release in 2009, Redis has gained immense popularity and become one of the most deployed data storage platforms with a large community.

Despite its impressive set of features, Redis had one severe limitation – it was designed from the ground up to be used in standalone mode. Users that needed to scale beyond the capacity of a single machine had to come up with ad-hoc sharding solutions, however version 3.0.0 delivered a production ready clustering system that radically simplified a distributed Redis deployment.

Categories: Java

Properly Shutting Down An ExecutorService

Thu, 2016-04-14 13:01

I was recently working on an application that used hibernate for db access and lucene for storing and searching text. This combination was really great. It made searching really fast. And tomcat was used as the application container.

Sometimes I used to get this exception on redeploy:

Categories: Java

Java: More Typing With Less Typing

Thu, 2016-04-14 08:01

There are many things that prove divisive amongst software developers. For example, just ask a group of (more mature) developers whether they are a vi or Emacs user and this will normally result in a heated discussion on the merits of both (personally, I’m a hardcore vi man). Other subjects such as operator overloading (good or bad?) and static versus dynamic typing will always polarize developers.

I often hear criticism of Java because it is too verbose: “You need too much boiler-plate code, even for simple things,” “Why do I need to end every statement with a semi-colon? Other languages don’t require this” and so on. It is true Java does require more characters to be typed than some other languages.

Categories: Java

Java Quiz: Best Seats in the House

Thu, 2016-04-14 06:31

Here's the answer to last week's quiz, courtesy of Sar Maroof:

1. Calling the MyAbstract constructor

Categories: Java

Poll: What's Fun, Difficult, Unpleasant About Programming?

Thu, 2016-04-14 06:01

Programming is hard, but hard stuff can also be fun -- like when you're juggling six levels of abstraction and barely (but totally) keeping the namespaces straight; in the mental monad-zone nesting a dozen functions like mad; suddenly realizing that this whole block could be refactored into a five-line, more readable, much faster recursive procedure; churning out classes and having your tests pass on the first try.

But programming can be unpleasant too -- like when a stack trace tells you nothing at all what the heck, or when you have to untangle the lousy code some how-did-this-person-even-get-paid-for-this slapped together years ago, or maybe even when you can feel the technical debt growing but just don't have the time to do anything about it right now.

Categories: Java

Spring for Apache Kafka 1.0 Milestone 2 Available

Wed, 2016-04-13 13:01

I am pleased to announce that the spring-kafka (Spring for Apache Kafka) Second Milestone for version 1.0 is now available.

The artifacts org.springframework.kafka:spring-kafka:1.0.0.M2 and org.springframework.kafka:spring-kafka-test:1.0.0.M2 are available in the Milestone repository.

Categories: Java

The Flyweight Pattern

Wed, 2016-04-13 11:31

As a Java programmer you’ve probably heard to “Think in terms of objects”. Designing objects to the lowest levels of system “granularity” promote flexibility in the application. But, as a good programmer you also need to think about the performance of the application, in terms of the amount of resources required to run it. When you are dealing with a large number of objects, you need to be concerned about the resources the objects will consume. Each will need memory, and creating each will need CPU cycles.

“Use sharing to support large numbers of fine-grained objects efficiently.”

Categories: Java

Microservice Architectures With Spring Cloud and Docker

Wed, 2016-04-13 09:31

This article provides a starting point for understanding common Microservice architecture patterns by example of a proof-of-concept application built with Spring Boot, Spring Cloud, and Docker.

The code is available on Github, and images are available on Docker Hub. You can start the whole system with just one command.

Categories: Java

Object Construction and Validation

Wed, 2016-04-13 08:01

When porting Java code to Ceylon, I sometimes run into Java classes where the constructor mixes validation with initialization. Let's illustrate what I mean with a simple but very contrived example.

Some Bad Code

Consider this Java class. (Try not to write code like this at home, kiddies!)

Categories: Java

Simple Everyday Tips for Vaadin Developers (Part 1: Vaadin 6 to 7)

Wed, 2016-04-13 06:31

Everything started with the idea of migrating the JBoss BRMS Demo from Vaadin 6 to 7 and using the new Vaadin CDI Add-on. Since this is only a demo, the migration was relatively simple. Nevertheless, I found a lot of interesting code enhancement tips that can maximize the utilization of Vaadin core features and make the project more solid from UI perspective.

JBoss BRMS Demo running with Vaadin 6

This series will be divided into five parts:

Categories: Java

Configure Tomcat 9 for HTTP/2

Tue, 2016-04-12 13:01

One of the most important developments in JavaEE 8 will be support for HTTP/2 (now the official RFC 7540). The Java Community Process JSR-369 has been in development for almost 2 years now, and the specification leaders Ed Burns and Shing Wai Chan have done a great job in advancing its progress.

At the time of writing, three server vendors currently support Servlet 4.0: Apache Tomcat 9.0.0.M4, Jetty 9 and WildFly 10.0.0.Final. Let's have a look at how to configure Tomcat 9 to support it.

Categories: Java

Spring Boot With JSPs Using Undertow

Tue, 2016-04-12 11:31

This is a follow-up to my previous post Spring Boot with JSPs in Executable Jars.

Undertow is another alternative for using an embedded container with Spring Boot. You can find general information in the Spring Boot reference guide chapter Use Undertow instead of Tomcat. While I was working on updating the Spring Boot documentation regarding the JSP support for Tomcat, I noticed the following line in the reference guide for Spring Boot 1.3.3:

Categories: Java

Simplifying Nested Loops With Java 8 Lambdas

Tue, 2016-04-12 09:31

This is just a quick tip for everyone who has to work with multi-dimensional arrays in Java 8 (or newer).

In this case, you might often end with code similar to this:

Categories: Java

JDK 8: Arrays#sort vs. Arrays#parallelSort

Tue, 2016-04-12 06:31

In this article, we will discuss one of the JDK 8 feature called parallelSort. Before getting into the details of parallel sort, we will see sort method implementation.

public static void sort(Object[] a) { if (LegacyMergeSort.userRequested) legacyMergeSort(a); else ComparableTimSort.sort(a, 0, a.length, null, 0, 0); }

The sort method will use the “merge” sort algorithm or Tim Peters’s list sort algorithm to sort the elements. “Merge” sort will use divide and conquer methods to sort the elements. The lager array will be divided into two parts and then each part of the elements will be divided further until there are no possible way to divide. The individual chunks will be sorted based on an “insertion” sort algorithm and then the results will be merged. To sort the larger array, it will have performance problems.

Categories: Java

JWT Authentication With AngularJS - Video and Tutorial

Tue, 2016-04-12 06:01

Lately I’ve been on the road, giving talks about web application security.JSON Web Tokens (JWTs) are the new hotness, and I’ve been trying to demystifythem and explain how they can be used securely. In the latest iteration of this talk, I give some love to Angular and explain how I’ve solved authentication issues in that framework.

However the guidelines in this talk are applicable to any front-end framework.

Categories: Java

An Introduction to the Java Collections Framework

Mon, 2016-04-11 12:02

This article is part of Marcus Biel’s free Java course focusing on clean code principles. In this piece, you will be given a high-level introduction of the Java Collections Framework (JCF). Collection is a word with several overloaded meanings, unfortunately. To clear things up, we will first discuss the word’s meanings upfront.

A video of this article is also available here.

Categories: Java

Quick Access to Eclipse IDE Features

Mon, 2016-04-11 11:31

As Lars points out on the ide-dev mailing list, a lot of Eclipse IDE users aren’t aware of some very handy features, especially the one-feature-to-rule-them-all: Quick Access.

In an Eclipse IDE, Quick Access will take you quickly to the feature you need. To activate Quick Access, type Ctrl+3 and start typing (or click in the entry field in the toolbar and start typing).

Categories: Java

Currying Functions in Scala

Mon, 2016-04-11 09:31

For a long time I couldn’t understand currying functions in Scala and how they work. That was really horrible! Occasionally I met the currying functions in the code and wasted too much time on reading them. So finally I decided to learn how they work and where they could be applied.

Let’s start from a definition. A currying function is a function which could accept a fewer number of parameters than are declared, then it returns a function with unused parameters. This definition is totally weird. In order to understand it we need to go through several examples. And be sure that you already know how simple Scala functions work.

Categories: Java

Java 8 – Default Methods in Interfaces

Mon, 2016-04-11 06:31

In this article we will explore the Java 8 default methods feature in interfaces. The Java 8 says “Default methods enable new functionality to be added to the interfaces in libraries and ensure binary compatibility with code written for older versions of those interfaces”.

As Java evolved over the years, the interfaces introduced in the Java library require adding new functionality. If you add new methods in the interface without having default methods feature, all the classes which already implemented the interfaces should undergo for a change. This results in changing thousands of lines of code. To avoid this, the Java 8 introduced default method feature. That is, if you want to add any functionality to the existing interface, you can add it by using default method feature without affecting the implementations.

Categories: Java