A Beginner’s Guide to Kotlin

This post will provide you with:

  • A brief overview of Kotlin’s features
  • A guide for solving a basic problem and building a “Hello, World!” app.
  • A brief breakdown on running a Kotlin Spring Boot application with authentication via Okta 

Kotlin is a modern language that is statically typed within the JVM. It’s a multi-purpose, cross-platform, free and open-source language developed by JetBrains under the Apache 2.0 license. Kotlin has constructs for both Object Oriented and Functional programming styles (as well as mixed). It can be used for many types of development; web, server, and client, and mobile—using most Java IDEs.

Client Oriented Dynamic Search Query Supporting Multiple Tables in Spring

Backdrop

To begin with, this an example primarily written in Springboot to leverage the benefits of Spring Data JPA. The main motive of this article to have a simple and common data search logic that applies to almost every table and is client-oriented. This article is heavily inspired by one from Eugen Paraschiv, I recommend going through his tutorials to learn Spring professionally.

Pre-Requisites for Getting Started

  • Java 8 is installed.
  • Any Java IDE (preferably STS or IntelliJ IDEA).
  • Basic understanding of Java and Spring-based web development along with Spring Data JPA.

I used Spring Initializer to add all the dependencies and create a blank working project with all my configurations. I used Maven as project build type and Java 8 as language, though this part is up to your choice as long as it is supported by spring. Below are my required dependencies which can easily be added from spring initializer. 

Java: It’s Time to Move Your Application to Java 11

In the past few years, several exciting things have happened in the Java world, among them is certainly the new version control. Previously, it could take anywhere between two or three years for a new version to be released. Now, there's a new cadence every six months in addition to the LTS for new versions of the JVM. Currently, there is already work to deliver Java 14, however, as the latest research reveals, the use of Java 8 remains very strong for the market. This post aims to encourage and discuss the reasons for upgrading to Java 11, the current Java LTS.

There are several Java surveys that show that Java 8 is still the most popular version among developers, such as the SNYK that shows Java 8 with 64% against 25% in Java 11 and Eclipse Foundation where the number is even more significant with 80% with Java 8 against 20% with Java 11.

Spring Boot Quickstart

Spring Boot is a Java framework that allows the development of web services. This article will show you all the steps to get started with Spring Boot and create your first web service on IntelliJ IDE.

First of all, you need to install the following requirements: 

Log4j Bug — Slows Down Your Application

Learn how to troubleshoot your application.

Recently we were troubleshooting a popular SaaS application. This application was slowing down intermittently. To recover from the problem, the application had to be restarted. This application was slowing down sometimes during high traffic volume periods; sometimes during low traffic periods as well. There was no cohesive pattern.

You may also like: How Slow App Performance Can Impact Your Bottom Line

Modifying Variables Inside Lambdas

Occasionally, we will run into a situation in which we want to modify a variable inside a Lambda expression, but when we try to do so, we get a compile-time error saying: 

A variable inside Lambda must be Final or Effective Final.

Spring Boot: Reading Resources

Learn how to read files from the resources folder in a Spring Boot application.

Reading files from a Spring Boot application is possible through Java 8 NIO API. This article demonstrates how to read files from the resources folder in a Spring Boot application, which is running as a standalone application or inside the Docker container. 

You may also like: Working With Resources in Spring

A Simple HTTP Server in Java

Do you want to implement an HTTP server, but do you not want to take any risk of writing a full-fledged HTTP server? Developing an HTTP server with full capability is not a trivial task. But Java has got a solution to this kind of problem. Java supports an in-built HTTP server. By just writing 100 lines of code, we can develop a somewhat-decent HTTP server that can handle HTTP GET and POST requests. We can also leverage it to handle other HTTP commands as well.

HTTPServer class

Java SDK provides an in-built server called HttpServer. This class belongs to com.sun.net   package. 

Lambda Expressions and Method References

Hello, friends this my first article on Java 8.

Today, I am going to share how lambda expressions and method references reduce boilerplate code and make our code more readable and compact. Suppose we have a Student class that has two fields, name and age. We are going to sort a student list with the help of the Comparator interface. After that, we will reduce the code step-by-step with the help of some of Java 8's new features.

Guide to Java Versions and Features

Java 8, Java 11, Java 13 — what's the difference?

You can use this guide to find and install the latest Java, understand the differences between Java distributions (AdoptOpenJdk, OpenJDK, OracleJDK, etc.), as well as get an overview of Java language features, including Java versions 8-13.

You may also like: Beyond Java 8

Background Information

First, let’s have a look at some common, practical questions that people have when trying to choose the right Java version for their project.

Test Automation: Seamless Integration of Tools and Frameworks

In this article, I want to give you an overview of how well the latest technologies can be integrated seamlessly into a test automation framework. Test automation is also an integral part of the software development lifecycle, and we want our test automation framework to contain all the latest features with minimal effect.

In this article, we build a sample test automation framework that consists of tools like Spring Boot, Cucumber, Java 8, and Serenity to test a sample Calculator application.

Constructor Value Vs. Observer in Java

Who wins in the battle between Constructor Values and the Observer? Well, it depends.

Who Belongs to Whom?

It is common to connect two components using constructor parameters. This procedure can be seen very clearly, for example, in the construction of graphic surfaces. Take the following source code:

public class SubView {
  private MainView mainView;
  public SubView(MainView mainView) {
    this.mainView = mainView;
  }
  public void buttonClicked(String input) {
    mainView.setInputValue(input);
  }
}


Should I Parallelize Java 8 Streams?

[Java] parallel streams

In Java 8, the streams API is easy to iterate over collections, and it's easy to parallelize a stream by calling the parallelStream() method. But should we be using parallelStream() wherever we can? What are the considerations? 

You may also like: Think Twice Before Using Java 8 Parallel Streams

Look at the following ParallelStreamTester class to generate collections of different sizes for the purpose of testing parallel streams performance against a sequential stream.  

Optional.orElse() Vs. Optional.orElseGet()

Learn more about programming Java Optionals

A very common misunderstanding, as well as bad usage, can prevail if you simply go by the dictionary and semantic definition of Optional.orElse() and Optional.orElseGet().

A smart man makes a mistake, learns from it, and never makes that mistake again. But a wise man finds a smart man and learns from him and how to avoid the mistake altogether.

Five Languages to Learn as a Java Programmer

Here are the five languages you MUST learn as a Java developer!

As a programmer, you want to explore new things. Learning a new language gives you a different perspective when solving problems.

So what are the five languages that a Java developer must explore?

All Things Java 8 [Tutorials]

Java 8
No matter what version of the JDK we are on, Java 8 is not going anywhere.

Java 8 introduced a new era of Java. Everything from lambda expressions and functional programming to Streams and collections — DZone was there to document it all.

So whether you're migrating over to Java 9 or Java 11, or maybe even Java 13, Java 8 concepts and features are still very much alive in the JDK. And understanding these core concepts can help tremendously when it's time to move beyond Java 8.

Is the Book ”Java Concurrency in Practice” Still Relevant in the Era of Java 12?

One of my readers, Shobhit, asked this question on my blog post about must-read advanced Java books: is the book "Java Concurrency in Practice" still relevant? I really liked the question and thought many Java programmers might have similar thoughts whenever someone recommends this popular Java read.

When this book was first published in 2006, the Java world was still not sure of about new concurrency changes made in Java 1.5. I think this was the first big attempt to improve Java's built-in support for multi-threading and concurrency.