Java Lobby Announcements

Subscribe to Java Lobby Announcements feed
Recent posts in Java on
Updated: 13 hours 51 min ago

Mastering Java 8 Streams (Part 3) [video]

Mon, 2018-04-09 09:01

In the previous episodes, you learned quite a lot about Java 8 Streams, from the basics to more advanced concepts like sorting and flatMapping.

Now it is time to have a look at the find* and match* methods, like findAny, or allMatch, including when and how to use them. What do they do anyway? You'll find out in this short and practical screencast.

Categories: Java

Waiting for Another Thread With CyclicBarrier

Mon, 2018-04-09 06:01

The CyclicBarrier lets a set of threads wait until they have all reached a specific state. Initialize the CyclicBarrier with the number of threads that need to wait for each other. Call await to signal that you are ready to proceed and wait for the other threads. We will see how to use it by looking at two real-life examples.

How to Use CyclicBarrier

The first use case of CyclicBarrier is to signal that we are ready to proceed and wait for the other threads. The class DistributedTxCommitTask from the Blazegraph open source graph database uses the CyclicBarrier to coordinate multiple threads. The following shows the creation of the CyclicBarrier:

Categories: Java

JλVλ 8 (A Comprehensive Look)

Sun, 2018-04-08 07:01

Let's start from the start and have a look at the journey of Java.

Note: The Java 11 features mentioned above are not the finalized ones to be included in the Java 11 release. This list just mentions the features that most probably will be included or removed. Also, note that Graal — the experimental JIT compiler listed under Java 10 — was already added in Java 9, but it could not be enabled through JVM arguments back then. For more information on Graal, have a look at Graal, Sulong - LLVM bitcode interpreter, JVMCI - JVM Compiler Interface, Truffle, SubstrateVM - AOT compilation

Categories: Java

Practical Byte Code Engineering

Sat, 2018-04-07 12:42

Over the past few years, I have written a few blogs about how to use byte code engineering. My first article was a brief overview while others discussed specific case studies.  In hindsight, I think I have overlooked covering the basic building blocks of byte code engineering: the Java agent and the Instrumentation API. Additionally, some downloadable and practical byte code engineering example projects might helpful. This article aims to reconcile these issues.

There are two main ways to instrument Java byte code. One way is to modify your target classes prior to run time and then adjust your classpath (and possibly boot classpath) accordingly to point to your instrumented classes, Fortunately, (since Java 1.5), there is a specific Java API for instrumentation (among other things) called JVM TI (Tooling Interface). JVM TI allows you to attach native or Java agents. This blog will focus only on Java agents (I tell people I prefer them for their platform portability, but the truth is my C programming skills are really rusty).

Categories: Java

Template Method Pattern Revised

Sat, 2018-04-07 06:01

When I started programming, there was a design pattern among all the others that surprised me for its effectiveness. This pattern was the Template Method pattern. While I proceeded through my developer career, I began to understand that the inconsiderate use of this pattern could lead to a big headache. The problem was that this pattern promotes code reuse through class inheritance. With functional programming became mainstream, this pattern can be revised using lambda expressions, avoiding any inheritance panic.

The Original Pattern

It’s the year 2004. Martin Fowler had just published one of its most popular post Inversion of Control Containers and the Dependency Injection pattern (IoC). The pattern is a concretization of the famous Hollywood Principle, which states

Categories: Java

Spring Boot Under the Hood

Fri, 2018-04-06 22:01

Spring Boot has created such a hype and I feel understanding the basics is necessary for any seasoned developer.

When we do a, it starts the application, and we have a working application serving our needs (if coded properly, of course).

Categories: Java

This Week in Spring: Kotlin DSL, Java 10, and JUnit

Fri, 2018-04-06 18:01

Hi, Spring fans! What a week! This week I'm in beautiful Dallas, TX, for the Spring One Tour Dallas event which is, like so many of the other cities already, utterly and completely sold out! What a crowd!

Wow #SpringOneTour Dallas, you're so #bootiful!

Categories: Java

Configurations: Are You Doing it Wrong?

Fri, 2018-04-06 09:01

Let’s go over some configuration formats that most of us may be familiar with. Talking about the good old days (not really sure about “good” though), the de-facto standard configuration format in Java was properties. Wait... This historic configuration format is still widely used nowadays. The parser (a.k.a. java.util.Properties, a.k.a. the Hashtable with load and store functions) was released in JDK 1.0. Do you know that you can parse .properties file, store them in a Properties object (Hashtable), and then export them into an XML file? It sounds promising until you see its DTD (Not Schema).

<!-- Copyright 2006 Sun Microsystems, Inc. All rights reserved.--> <!-- DTD for properties --> <!ELEMENT properties ( comment?, entry* ) > <!ATTLIST properties version CDATA #FIXED "1.0"> <!ELEMENT comment (#PCDATA) > <!ELEMENT entry (#PCDATA) > <!ATTLIST entry key CDATA #REQUIRED>

Categories: Java

Introducing Combinators (Part 2)

Fri, 2018-04-06 06:01

This issue of The Bounds of Java Newsletter is the second part of a series about combinators. Here we introduce additional combinators and show how they can be implemented by building on some combinators presented in the previous newsletter.

More Combinators

In the previous part of this series, I introduced the Before, After, and Around combinators. Let's go on and show more combinators and how we can use them.

Categories: Java

Hibernate Tips: How to Map a View With Hibernate

Thu, 2018-04-05 22:01

Hibernate Tips is a series of posts in which I describe a quick and easy solution for common Hibernate questions. Some of the most popular tips are also available as a book.

If you have a question for a future Hibernate Tip, please leave a comment below.

Categories: Java

Java EE 8's Security API: Overview

Thu, 2018-04-05 18:01

Probably the single most significant new feature added to Java EE 8 is the new Security API.

The primary motivations for this new API were to simplify, standardize, and modernize the way security concerns are handled across containers and implementations. And they have done a great job.

Categories: Java

Spring Tips: Spring Cloud Stream Kafka Streams [Video]

Thu, 2018-04-05 12:01

Hi, Spring fans! In this installment (the first of 2018!) of Spring Tips, we look at stream processing in Spring Boot applications with Apache Kafka, Apache Kafka Streams, and the Spring Cloud Stream Kafka Streams binder.

Speaker: Josh Long

Categories: Java

Equality, Hash, and Map Implementations in Java

Thu, 2018-04-05 09:01

The parent of all 'Object' classes in Java has, among many, two notable methods: equals and hashCode. For the most of the part, we can go about without tinkering/overriding these methods, but they play a significant role when we are dealing with any kind of data structure whose implementation depends on hashing. Maps, Sets, and their various derivatives and implementations of the Java Collection framework depend on the hashing of objects. Let's consider a situation where we have to create a set of some objects for our consideration.

class Room{ private String name; private Integer capaciy; public Room(String name, Integer capacity){; this.capacity=capacity; } //getters and setters //original inherited equals and hashCode }

Categories: Java

SOLID Principles: Open/Closed Principle

Thu, 2018-04-05 06:01

Previously, we talked about the single responsibility principle. The open/closed principle is the second SOLID principle.

“Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification.”

Categories: Java

Introduction to AssertJ [Snippets]

Wed, 2018-04-04 22:01

AssertJ is a library used to provide assert statements for Java. It is a fork of the FEST-Assert library.

assertThat() is the main method to be used.

Categories: Java

Java Annotated Monthly: April 2018

Wed, 2018-04-04 18:01

This month it’s me, Trisha Gee, back at the helm of Java Annotated Monthly! The big news this last month was the release of Java 10, so soon after Java 9 that the hype still hasn’t died down from the release of Jigsaw.  This edition will contain the usual roundup of Java news, including Java 10, and a bunch of interesting tutorials and titbits for Java and related languages, frameworks, and libraries.


It’s Trisha back at the helm, and you know I like not only to bring you the news, but also to link to articles that teach/remind us of techniques/principles/facts Java developers should probably know.

Categories: Java

Configuring Spring in Stand-Alone Apps

Wed, 2018-04-04 12:01

Spring is a powerful framework — and not only for dependency injection. It can strongly benefit applications as a whole. Sometimes, you need to create your own highly customized stand-alone application instead using an out-of-the-box Spring Boot solution.

Typical cases are custom utility applications used for one-time jobs like email scraping for needed information or custom database migration.

Categories: Java

A Detailed Guide to EJBs With Code Examples

Wed, 2018-04-04 09:01

By 1996, Java had already become popular among developer for its friendly APIs and automated Garbage Collection and was starting to be widely used in back-end systems. One problem, however, was that most of these systems needed the same set of standard capabilities — such as persistence, transaction integrity, and concurrency control — which the JDK lacked at that time. That, naturally, led to many home-grown, closed implementations.

IBM stepped forward and released the Enterprise Java Bean (EJB) specification in 1997, with the promise that developers could write code in a standard way, with many of the common concerns automatically handled.

Categories: Java

How to Compile a Class at Runtime with Java 8 and 9

Wed, 2018-04-04 06:01

In some cases, it's really useful to be able to compile a class at runtime using the java.compiler module. You can, for example, load a Java source file from the database, compile it on the fly, and execute its code as if it were part of your application.

In the upcoming jOOR 0.9.8, this will be made possible through As always with jOOR (and our other projects), we're wrapping existing JDK API, simplifying the little details that you often don't want to worry about. Using jOOR API, you can now write:

Categories: Java

Cloud-native Development With Microprofile 1.2

Tue, 2018-04-03 18:01

The purpose of this blog post is to provide an overview of the APIs and specifications in the Eclipse Microprofile 1.2 release. In particular, I'll try to connect these specifications and APIs with their architectural purpose. Where do they fit and why? If you're thinking of moving your Java application to the cloud, then this post might be for you.

Cloud Native Applications

Cloud native mean different things to different people. Let's step back a bit and establish a definition useful to frame this discussion. In this article, we will lean on the description provided by the Cloud Native Computing Foundation. According to their terms, cloud native computing defines a software stack that is:

Categories: Java