Java Lobby Announcements

Subscribe to Java Lobby Announcements feed
Recent posts in Java on DZone.com
Updated: 3 hours 17 min ago

Operator Overloading and Conventions in Kotlin

Sat, 2017-10-07 07:01

Kotlin supports a technique called conventions, which everyone should be familiar with. For example, if you define a special method plus in your class, you can use the + operator by convention.

In this article, I want to show you which conventions can be used and will provide some Kotlin code demonstrating the concepts, of course.

Categories: Java

Java Command-Line Interfaces (Part 17): jw-options

Fri, 2017-10-06 22:01

The JavaWorld article Processing command line arguments in Java: Case closed by Dr. Matthias Laux introduces a simple Java-based library for processing command-line arguments that I'll refer to in this post as jw-options. The referenced article provides background information on why certain design decisions were made in the construction of the Options class. The "Conclusion" of the article describes the advantage of using the accompanying class and library: "This article describes a Java class that allows for the convenient processing of command line options for Java programs. The structure is flexible enough to handle even complex situations, while at the same time offering an API that allows for the definition of acceptable command line syntax with limited coding effort."

The "library" introduced by this JavaWorld article consists of three Java classes: Options, OptionData, and OptionSet. This is demonstrated in the following screen snapshot that displays the contents of options.jar.

Categories: Java

This Week in Spring: Spring 5.0 Edition!

Fri, 2017-10-06 18:01

Welcome to another installment of This Week in Spring! This last week’s been nuts! So much good stuff on offer. Spring Framework 5.0 is now available! And with Spring Framework 5.0 comes a deluge of releases, all of which you’ll see in this post. Also, this week I — and others from the Pivotal and Spring teams — are at JavaOne and I hope you’ll come find us and say hi at our booth or the various talks.

Categories: Java

JavaOne 2017: Oracle vs. Amazon, Going Serverless, and Open Source

Fri, 2017-10-06 12:01

I am back at JavaOne 2017 this year! The conference is taking place at Moscone West and the Marriott Hotel in San Francisco.

Java EE and MicroProfile

What is new in Java EE 8? Well, there is the alignment with Java SE 8. The emphasis is on concurrency utilities and composability. JAX-RS 2.1 has reactive support as well as asynchronization on both server and client. Java EE 8 also contains Servlet 4.0, which supports HTTP 2.0. Also, CDI 2.0 has extended for multi-thread events and improvements.

Categories: Java

Configuring Spring Boot on Kubernetes With Secrets

Fri, 2017-10-06 09:01

In Part 1 of this series, we saw how to use ConfigMaps to configure a Spring Boot app on Kubernetes. ConfigMaps are OK when we use simple configuration data that does not contain sensitive information. When using sensitive data like API keys, passwords, etc., Secrets are the preferred and recommended way. In this second part of the series, we will explore configuring Spring Boot on Kubernetes with Secrets.

The sources for this blog post are available in my GitHub repo.

Categories: Java

Java 9: Reflection and Package Access Changes

Fri, 2017-10-06 06:01

Java 1.9 is out, and many companies will now be evaluating Java 1.9 and migrating their codebase over to it. I am not going through a similar process.

I have some fairly simple code that I was using for HTTP requests. This was originally written in Java 1.8. To keep my codebase as simple as possible, and because I wanted to use no external libraries, I used an HttpURLConnection for HTTP requests.

Categories: Java

Spocklight: Reuse Variables in Data Providers

Thu, 2017-10-05 22:01

Writing a parameterized specification in Spock is easy. We need to add the where: block and use data providers to specify different values for each set of values from the data providers our specifications are run, so we can test for example very effectively with multiple input arguments for a method and the expected outcome.

A data provider can be anything that implements the Iterable interface. Spock also adds support for a data table. In the data table, we define columns for each variable and in the rows values for each variable. Since Spock 1.1, we can reuse the value of the variables inside the data provider or data table. The value of the variable can only be reused in variables that are defined after the variable we want to reuse is defined.

Categories: Java

Spring Tips: Reactive Spring Security

Thu, 2017-10-05 18:01

Speaker: Josh Long

Hi Spring fans! In this tip, we’ll look at the reactive programming support in Spring Security 5.0. We’ll look at it in terms of its integration with Spring WebFlux, the reactive web runtime and framework in Spring Framework 5.

Categories: Java

Java Command-Line Interfaces (Part 18): JCLAP

Thu, 2017-10-05 12:01

Giles Winstanley's JCLAP (Java Command-Line Argument Parser) is the eighteenth library covered in this series of posts on Java-based command line processing libraries. This post's examples are based on JCLAP 1.4, which requires Java 8. The main JCLAP page states, "JCLAP helps Java developers to create simple-to-use command-line interfaces for their applications."

The "definition" stage is accomplished with JCLAP via invocation of "addXXXXXOption" methods on the CLAParser object. This post's example, as was the case for examples in the earlier posts in this series, defines two command line options, one for file path and name and one for enabling verbosity. The next code listing demonstrates how to use JCLAP to define these two command line options (full code listing is available on GitHub).

Categories: Java

Automata-Based Programming in Spring

Thu, 2017-10-05 09:01

Using FSM (finite state machines) for modeling in software development is not a new concept. Automata-based techniques have been widely used in domains like formal language analyses. However, applications of finite state machines were further investigated and applied as a general purpose program development methodology.

The programming paradigm in which the program, or part of it, is thought of as a model of a finite state machine (FSM) is called Automata-Based Programming.

The term Automata-Based Programming was introduced in 1997 on a multi-agent systems conference (held near St. Petersburg) by N. Polikarpova, one of the authors of the book Automata-Based Programming (called Автоматное программирование in Russian). The English term was mentioned a bit later in an English article published by Shalyto. It was named Automata Programming or a Switch technology. This technology is based on the projecting of systems or parts of them as sets of connected finite automata.

Categories: Java

@Inject Boosts Vert.x Apps

Thu, 2017-10-05 06:01

Last year, the Weld team announced the weld-vertx project with the goal of bringing the CDI programming model into the Vert.x ecosystem. But wait, Vert.x defines itself as "a toolkit for building reactive applications on the JVM". If you look into the docs, you'll come across words like asynchronous, reactive, and non-blocking. Weld (a CDI reference implementation), on the other hand, comes from the Java EE world, which is based on standards and traditional (mostly synchronous) concepts.

So what is the point?

Categories: Java

5 Trends to Watch in the Java Ecosystem

Wed, 2017-10-04 22:01

Over the last couple of months, a number of announcements have been made that have changed the Java ecosystem. These changes could have a long-term impact on Java developers and the Eclipse community. This week at JavaOne, I expect we will hear about a lot of these changes. For the most part, I think there are five key trends that all Java developers will need to watch. If you can’t make it to JavaOne, many of these trends will also be highlighted at EclipseCon Europe.

1. Adoption of Java 9

Java 9 is finally out the door. This release has been a long time in development, so now the process of adoption will begin. The first step in adoption is making sure developer tools work with Java 9. Eclipse JDT, for example, supported Java 9 from day 1.

Categories: Java

Java Annotated Monthly: October 2017

Wed, 2017-10-04 18:01

Java 9 is here! At long last. This month we have lots of Java 9 content, of course, but that’s actually not the only Big News: not only is Java EE 8 also now available, but we can look forward to a new release of Java every six months. So we’re celebrating Java 9, but we’re already anticipating Java 10. It might not even be called Java 10…

Java 9

Java 9 is out at last! In this section, we have links to articles about the release, tutorials and reference documentation for some of the main features, and some commentary on the release and its features.

Categories: Java

JavaOne 2017 Day 1 Keynote: Notes and Thoughts

Wed, 2017-10-04 12:01

Unfortunately, I wasn’t lucky enough to attend JavaOne 2017 this year, so I’m catching up this evening and watching the recording of the Day 1 Keynote here.

A few notes, key quotes, and thoughts (screenshots taken from the video):

Categories: Java

Java 9: The Good, the Bad, and Private Interface Methods

Wed, 2017-10-04 09:01

Java 9 was released a few weeks ago. Check the release notes, they include many interesting features. However, I think that not everything is as good as Oracle and Java adepts seem to picture it. I see three trends in the Java world, which are good, bad, and ugly, respectively. Let's start with the good one.

Birdman (2014) by Alejandro G. Iñárritu The Platform

The first trend is an obvious improvement of the platform that compiles Java, packages JARs, and runs the bytecode. It definitely becomes better with every new Java release. Here is a list of improvements Java 9 made, which are very useful, without a doubt:

Categories: Java

Build a Secure Notes App With Kotlin, TypeScript, and Okta

Wed, 2017-10-04 06:01

I love my job as a developer advocate at Okta. I get to learn a lot, write interesting blog posts and create example apps with cool technologies like Kotlin, TypeScript, Spring Boot, and Angular, which I’m about to demo. When it comes to writing Hello World apps with authentication, I can whip one out in a few minutes. That isn’t because I’m a particularly good programmer, it’s because the languages, frameworks, tools, and platforms available to developers are impressive.

In this tutorial, I’ll show you how to write a note-taking application in Kotlin and TypeScript — two of the fastest growing languages of 2017. You’ll use two popular frameworks, Spring Boot and Angular, to make development super fast. Along the way, I’ll show you a few tips and tricks from my favorite development IDE, IntelliJ IDEA. Finally, we’ll leverage Angular CLI and start.spring.io to generate application skeletons.

Categories: Java

Run Your Java App as a Service on Ubuntu

Tue, 2017-10-03 22:01

Say you have a JAR file and you need to run it as a service. Additionally, you want it to start automatically if/when system restarts.

Ubuntu has a built-in mechanism to create custom services, enabling them to get started at system boot time and start/stop them as a service. In this post, I am going to share a simple and elegant way to create a service wrapper for your JAR file so you can run it as a service. Here we go.

Categories: Java

Kotlin Generic Extension Functions

Tue, 2017-10-03 18:01

I have been educating myself in Kotlin recently, and one of the most powerful features that Kotlin provides is extension functions. The simplest example of an extension function that I can come up with is: fun String.addOne() = this + "1" 

And then, println("Boba".addOne()) leads to an output of: Boba1

Categories: Java

A Reactor Core Tutorial

Tue, 2017-10-03 12:01

Reactive programming is about building asynchronous, non-blocking, and event-driven applications that can easily scale.

Reactor is a Reactive library for building non-blocking applications. It is based on the Reactive Streams Specification. Java 8 is required to use this library, and it is integrated into Java 9.

Categories: Java

Sneakily Throwing Exceptions in Lambda Expressions

Tue, 2017-10-03 09:01

Handling checked exceptions in lambda expressions can often be frustrating. Luckily, there is a type inference rule that we can exploit.

Java 8 Type Inference

While reading through the Java Language Specification, we can find interesting information:

Categories: Java

Pages