Java Lobby Announcements

Subscribe to Java Lobby Announcements feed
Recent posts in Java on
Updated: 10 hours 50 min ago

Writing a Slack Plugin is One of the Easiest Things to Do... Sort of

Wed, 2016-01-13 08:02
Slack is the little chat app that could. It’s had a meteoric rise to becoming one of the most popular productivity tools amongst developers. Whilst it’s great as a chat app on its own, one of the reasons it’s become so popular is the huge plugin ecosystem that has grown around it. Slack has integration with calendar systems, weather systems, log scrapers, deployment tools and much more. You can really do anything from it.

Where this really gets exciting is in creating your own Slack integrations. You can hook your Slack system up to your internal processes, and best of all it’s exceptionally easy to do. Slack has created a simple yet powerful API- all you need is a REST service. In this tutorial I’ll be showing you how to do just that to create your own slash command to display images of Nicholas Cage in your Slack chat, taking advantage of the PlaceCage API.

Creating a Custom Slash Command

In slack, a slash command is a forward slash, followed by the command, and then some optional parameters. For example, “/remind me in ten minutes to get a drink” will remind you in ten minutes to get a drink. We can create our own slash commands to do almost anything we want.

Categories: Java

Using Wiremock to Test Against 3rd Party Services Offline

Tue, 2016-01-12 10:45
I’ve recently been playing Stockfighter, the programming game released by Patrick McKenzie. It’s great fun and you should totally try it. The game is based mostly around a REST API, and so I ended up needing to create a basic Java abstraction of the API.

Being a bit obsessed with TDD I wanted to create some tests for this first. Writing code to call third party APIs and testing by calling the external service can be immensely frustrating and slow, so I wanted a better way to stub out standard responses. I’m also currently travelling a lot, often without internet, but wanted to be able to keep coding up against the API having saved the docs offline (thanks evernote!)

There are a number of libraries available for this, but none of them struck me as a good way of doing TDD until I stumbled across Wiremock. As you can imagine from the name, it can mock third party calls and allow you to make assertions on them. It uses a Hamcrest like syntax, and also allows you to match things like the request body arguments. I’m a huge fan, and it allowed me to complete my API implementation on a plane with no internet.

Categories: Java

One Small Error in Java Code, One Giant Leap for Java Code Quality

Tue, 2016-01-12 07:42

In this series of posts I am covering some of the many ways you can benefit from XpoLog and especially on how to get the most valuable information from your log4j event logs.

By running the XpoLog Analytic Search on your log4j data, you can among other things measure your application performance and thread activity, measure code activity with class and method analytics on log4j, build security analysis, and make use of various visualization gadgets for maximum analysis.

Categories: Java

Top Developer Languages of 2015 [Infographic]

Tue, 2016-01-12 07:24

In case you haven't finalized your resolutions for the 2015 year yet, why don't you take a peek at the top development languages from 2015 and pick one to study this year? Check out the infographic below and good luck in your studies!

Categories: Java

The Observer Pattern Using Modern Java

Mon, 2016-01-11 13:36

The Observer Pattern, or the Publish-Subscribe (Pub-Sub) Pattern, is a classic design pattern codified by the Gang of Four (GoF) Design Patterns book in 1994 (pg. 293-313). Although this pattern has quite a long and storied history, it is still applicable in a wide range of contexts and scenarios, and has even become an integral part in the Standard Java Library. While there are numerous useful articles on the topic of the Observer Pattern, and its implementation in Java, many focus on the strict implementation of the pattern in Java, rather than on the idiosyncrasies and common issues developers using the Observer Pattern in Java will experience.

This article is written with the intent of filling this gap: This article illustrates a simple implementation of the Observer Pattern using modern Java 8 constructs and uses this basic implementation to explore some of the more sophisticated problems associated with this classic pattern, including the use of anonymous inner classes and lambdas, thread safety, and non-trivial and temporally-expensive observer implementations. This article is by no means comprehensive and many of the intricacies of this pattern are beyond the scope of a single article, but when complete, the reader will understand not only the Observer Pattern, but its common peculiarities in modern Java and how to approach some of the most common issues that arise when implementing the Observer Pattern in Java.

Categories: Java

Q&A with Terence Parr on ANTLR

Mon, 2016-01-11 09:01

What was the inspiration for the development of ANTLR? 

By around 1988, I had built a lot of parsers, but manually as recursive-descent parsers rather than via yacc grammars. I didn't understand those infernal yacc reduce-reduce conflicts and didn't like the black box state machine you got out of yacc anyway. I liked the ability to step through my recursive-descent parsers with a debugger. However, grammar formalisms are very useful and I used them as comments in front of my parsing functions. For example I would do something like:

Categories: Java

Leaner Java Collections With FastUtil

Mon, 2016-01-11 07:34

In response to my recent post Discovering a Trove of Java Primitives Collection Handling on the GNU Trove library, TheAlchemist pointed out some advantages of fastutil over trove: "I much prefer fastutil (, because it's still in active development, has more features, supports large sizes (> 2^32), and has better documentation." Attila-Mihaly Balazs has seconded this: "I second @TheAlchemist's recommendation for fastutil! It's a great library." In this post, I look at fastutil from some of the same perspectives that I previously looked at trove.

The main fastutil page describes fastutil as an extension of the JavaTM Collections Framework that provides "type-specific maps, sets, lists and queues with a small memory footprint and fast access and insertion" along with "big (64-bit) arrays, sets and lists, and fast, practical I/O classes for binary and text files." The license for fastutil is Apache License, Version 2 and the current version of fastutil requires Java 7 or newer. There are currently (as of this writing) "unmaintained" versions of fastutil available for download as well for Java 6 and Java 5 as well.

Categories: Java