Java Lobby Announcements

Subscribe to Java Lobby Announcements feed
Recent posts in Java on
Updated: 1 hour 30 min ago

Useful Scala Compiler Options (Part 3)

Fri, 2016-10-07 11:31

In my previous two posts on Scala Compiler options, we saw a number of options that can improve your experience developing Scala. In this post I want to focus on one option in particular:
-Xlint. If you thought the other options made your life better, this one will improve it by leaps and bounds.

-Xlint enables a number of linting options in the Scala compiler that will produce warnings about various code smells. There are 15 linting options in Scala 2.11. By default, they are disabled, but can all be enabled by adding -Xlint to your scalacOptions setting. They can also be enabled individually by using -Xlint:<option>. Most of the resources I've seen suggest enabling all of the options and calling it a day. This is good advice and you should probably follow it, but I wanted to take some time to dig into what you are actually getting when you enable this option. In addition, it's very helpful to see the linting warnings to understand what issue the compiler has surfaced and why it was produced.  

Categories: Java

JavaOne 2016 Observations

Fri, 2016-10-07 10:01

I recently got back from JavaOne, where there was a surprising amount of good stuff in the technical sessions, including a number of very well-prepared presentations on Java 9 modularity and the best way to migrate existing code to Java 9. We also got a hint of Oracle’s plans for Java EE. On the other hand, there was disappointingly little on what we might expect regarding the longer-term future of Java, two or more versions down the road.

Java 9 and Modules

To me, the most interesting thing discussed at JavaOne was the upcoming release of Java 9. While Java 9 contains a number of new APIs, by far the most important new feature is the addition of modules (also known as “Project Jigsaw”). Modules are a way of much more closely controlling the encapsulation of APIs so that Java code can only access APIs explicitly exported by a module. Modules also specify what other modules they require, which allows for compile-time and run-time checks to determine whether all the required components are present. Finally, modules are a much more straightforward and reliable alternative to the traditional Java classpath, and allow us to avoid “classpath hell.”

Categories: Java

Apache PDFBox. Don’t Leave Home Without It.

Fri, 2016-10-07 09:01

Scenario: You have to generate a multiple page PDF report from production data. Each page must be a PDF page that will show your production data and allow users to change it through the use of text fields or text areas. Each report could have from 1 to 50 pages, each page is divided into sections, and each section can have 20 UI components (text fields and text areas). One page can contain from two sections to eight sections, depending on what specific template is it used for that page.

Please see below how the template of such page might look like:

Categories: Java

Asynchronous Communication With JAX-RS 2

Fri, 2016-10-07 07:31

Asynchronous communication has become more important nowadays, especially as data become more voluminous every day. 

One of the simplest cool new features in JAX-RS 2 is asynchronous processing. What's really nice is that async processing has been added both to client and server side APIs.

Categories: Java

Exploring a Top-Down SOAP Service (Part 2)

Fri, 2016-10-07 06:31

When we left off last time, we had succeeded in getting a bare-bones WSDL definition to generate some code, using the Apache CXF cxf-codegen-plugin (Maven).

I added only the absolutely necessary pieces to the WSDL, one step a time, so that we could observe what errors were produced, and so we could learn what we might be missing. Hopefully, this might be a helpful reference if you ever encounter some error message.

Categories: Java

A Java Developer's Guide to Migration

Thu, 2016-10-06 13:01

This article is featured in the new DZone Guide to Modern Java, Volume II. Get your free copy for more insightful articles, industry statistics, and more. 

Companies with desktop applications written in Java are under increased pressure to provide their users the freedom of a responsive web experience. Ideally, you could just run a desktop-style application inside a browser, and for a long time applets have made it possible to do just that. However, applets work using a protocol called NPAPI, which has been deprecated in most recent browsers. Today, the only real option to run a web application is to get pure HTML5 into the browser — not easy for most desktop developers given the new set of styling, scripting, and markup languages they have to learn.

Categories: Java

Our Next Stop in the Software Journey: A Top-Down SOAP Service (Part I)

Thu, 2016-10-06 11:31

In our continuing make-believe story, you wrote some useful code for yourself in Java a year ago because you had a regular need. Soon, you turned it into a reusable component in its own project. (Shape calculator: project shape-calc-jpa-hibernate.) You then wrapped it in a command-line application.

Others in your department saw it, wanted it. Someone later suggested you provide a web application front-end as well, which you delivered.

Categories: Java

The Rise and Fall of Scala

Thu, 2016-10-06 10:01

Five years ago, Scala seemed like the next big thing in programming languages because it elegantly enabled functional programming within an object-oriented paradigm. Today, Scala’s popularity seems to be fading, with companies like LinkedIn and Yammer moving away from it. The TIOBE index ( of software language popularity ranked Scala at #13 in 2012; now it’s fallen to #32 in August 2016, being used by less than .6% of the programming community.

Here’s another ominous sign for Scala: Lightbend, its parent company, is now releasing new frameworks with a Java API before the Scala version. Anecdotally, as CTO of a leading software product engineering company, I meet many software development managers, and I know of at least two who have made the painful decision to abandon Scala after more than a year of adoption. What happened? What gave Scala its initial popularity boost, and what caused its decline? Are there any use cases for which Scala is still the best choice?

Categories: Java

Spring Data Series: Spring Data in a Nutshell

Thu, 2016-10-06 09:01

In this series, we will deep dive into the Spring Data architecture. In this article, we will concentrate on the features of Spring Data and what it has to offer.

Why Spring Data?

Spring Data is an umbrella that takes care of SQL and NoSQL databases and reduces the effort to use them. The Spring community’s motto is to reduce boilerplate code, so the community invented Spring Data, which is taken one step forward than the database template. In a JPA template, although Spring hides the creation EntityManagerFactory managing Entity manager but the problem is we still have to maintain a DAO layer and provide CRUD operations for each entity. CRUD operations are similar in nature you have framed it in your mind but still, have to write or copy and paste same code over and over for different Entities.

Categories: Java

Gluon CEO Johan Vos: JavaOne on Mobile

Thu, 2016-10-06 07:31

After this year's JavaOne, I spoke with Johan Vos, CEO of Gluon, a cross-platform Java API for creating mobile Java apps. They created a JavaOne app for 2015 and 2016, and won the "Duke's Choice Award" for 2015 and 2014 at the conference. 

1. How Did You Like JavaOne This Year?

Every year, JavaOne provides a great opportunity to get in touch with Oracle, other companies, and members of the Java community, and to share the latest evolutions and ideas in Java. This year was no different.

Categories: Java

3 Ways to Use Redis Hash in Java

Thu, 2016-10-06 06:31

Needless to say, Map is vital and the most popular structure in Java. Redis has offered a data structure that closely resembles Java's Map structure, which has attracted a lot of interest from Java developers. There has been a growing number of Java libraries that talk to Redis, most of which have provided a way to interact with Redis Hashes. Let's compare three different ways of interacting with Redis Hahs in Java through examples of using three most popular Redis Java clients. In order to make them easy to understand and fairly comparable, each example uses the same popular binary codec, Kryo, to provide serialization/deserialization of the dummy data.

1. Jedis

Jedis only works with raw binary data so encoding/decoding logic are required each time when a Redis command is invoked. A Jedis instance also needs to be acquired each time from the instance pool before any command can be invoked.

Categories: Java Teaches Java on Mobile From Scratch

Wed, 2016-10-05 08:31

We’ve discussed before. It’s an MOOC (online course) that allows non-programmers to learn Java programming. The course uses mobile and Codename One as its vehicle to provide a learning incentive. The existing Codename One documentation and tutorials can be quite intimidating to a person who is a complete Java newbie, so this course is quite helpful in bridging that gap.

I think that learning GUI programming is probably the best way to learn programming, as it lets you "see" the results instantly and experiment. Mobile is the new GUI as it is the device that has brought computing to everyone and is deeply tied into our lives. Learning through a device that has such an emotional tie into our lives is far more effective than a "dry" server side tutorial.

Categories: Java

Migrating EJB2 Entity Beans to EJB3 and JPA

Wed, 2016-10-05 08:01

Scenario: you have to migrate all of the EJB2 Entity Beans from a legacy project to EJB3 Entity Beans with JPA. Hibernate will be your JPA implementation and Spring Framework cannot be used. No other layer that the EJB2 Entity Beans layer will be migrated.

The application also contains an EJB2 Session Beans layer. This one will not be replaced, but updated to work with the new EJB3 Entity Beans. (Note: this article will not explain the J2EE architecture. If you want to find more about that, please check here. Please take the patterns presented in the link with a grain of salt. Some of them are obsolete, but some still make sense.)

Categories: Java

Tutorial: Java and Maven in Eclipse Che

Wed, 2016-10-05 07:31

Eclipse Che was written in Java. Get started with the rich Intellisense and Java tools in this tutorial.

1. Start Che

Use your SaaS account for the following, or if you have installed Che, open a terminal and use the Che startup script:

Categories: Java

Scala: Work With Files and Directories

Wed, 2016-10-05 07:01

How often do you need to write or read files? This is a pretty common task in any more or less non-trivial project. Image upload process, CSV or XML parsing, XLS report generation etc. All these operations imply input or output processing. So I’m going to make an overview of the most powerful library for working with files in Scala.

Here is a list of operations which I want to cover:

Categories: Java

Can Spring Security Be Auto-Generated?

Wed, 2016-10-05 06:31

I’ve generally found security requirements are easy to state but hard to implement. So, I've been wondering if I can autogenerate my Spring Security configuration.

Security Requirements

Common security requirements are:

Categories: Java

An Opinionless Comparison of Spring and Guice

Tue, 2016-10-04 12:31

Recently, I had to delve into the play framework for a particular microservice at work. Now it is not exactly new, nor is Guice, nor DI, but coming from Spring world it was still kind of a shift in approach. There is a lot of documentation comparing Spring with Guice, stating which is better, why, and how.

In general, these articles discuss specific points where these two frameworks differ in their approaches and which approach seems better to the author. I am not sure these articles really help someone trying to take a dip in the other framework. We know the differing opinions, as they are stated by the authors of the respective frameworks in their own documentation as well.

Categories: Java

Using Akka With Java

Tue, 2016-10-04 11:01

In the past few days, I've been working on a project with Akka using Java. It was an amazing experience, so I'm going to discuss how to use Akka in Java and write a test case.

If we look at the Akka's documentation, there is a class named UntypedActor to create an actor. But here, we're going to discuss the AbstractActor, which seems pretty concise.

Categories: Java

Bowling Kata in Kotlin [Video]

Tue, 2016-10-04 10:01

Sergio Rodrigo implements the Bowling Game kata in Kotlin using TDD, showing some of the features of the language, such as support for Functional Programming (Higher Order Functions, Lambdas and built-in functions), Pattern Matching, Extension Functions, Expression Bodies, and method names as free text. The kata is performed in a way that shows the expressiveness of Kotlin.

The Kotlin plugin for IntelliJ is used to show the IDE support for the language, using live templates and performing small automatic refactorings.

Categories: Java

12 Factors and Beyond in Java

Tue, 2016-10-04 09:01

This article is featured in the new DZone Guide to Modern Java, Volume II. Get your free copy for more insightful articles, industry statistics, and more.

For many people, “cloud native” and “12 factor applications” are synonymous. A goal of this article is to illustrate that there’s a lot more to cloud native than just adhering to the original 12 factors. As with most things, Java is up to the task. In this article we’ll examine concepts and code samples, taking a look beyond the standard 12 factors in the process, as Kevin Hoffmann does in his recent O’Reilly book Beyond the 12 Factor App.

Categories: Java