Console I/O in Java
1. Introduction In this quick tutorial, we’ll demonstrate several ways to use a console for user input and output in Java. We’ll have a look at a few methods of the Scanner class for handling input,...
View ArticleCalculate Age in Java
1. Overview In this quick tutorial, we’ll see how to calculate age using Java 8, Java 7 and Joda-Time libraries. In all cases, we’ll take the birth date and current date as input and return the...
View ArticleException Handling in Java
1. Overview In this tutorial, we’ll go through the basics of exception handling in Java as well as some of its gotchas. 2. First Principles 2.1. What is it? To better understand exceptions and...
View ArticleJava Weekly, Issue 236
Here we go… 1. Spring and Java >> Hands on MongoDB 4.0 transactions with Spring Data [spring.io] ACID transactions are now available when using a MongoDB replica set with Spring Data. Very...
View ArticleHow to Get the Size of an Object in Java
1. Overview Unlike C/C++ where we can use sizeof() method to get an object size in bytes, there’s no true equivalent of such method in Java. In this article, we’ll demonstrate how we can still get the...
View ArticleIntroduction to AWS Serverless Application Model
1. Overview In our previous article, we already implemented a full stack serverless application on AWS, using API Gateway for REST endpoints, AWS Lambda for business logic, as well as a DynamoDB as a...
View ArticleMonitoring Disk Usage and Other Metrics in Java
1. Overview In this quick tutorial, we’ll be discussing how to monitor key metrics in Java. We’ll focus on disk space, memory usage, and thread data – using only core Java APIs. In our first example,...
View ArticleKotlin with Ktor
1. Overview Ktor is a framework for building asynchronous servers and clients in connected systems using the powerful Kotlin programming language. It facilitates developing a standalone application...
View ArticleSpring Boot Integration Testing with Embedded MongoDB
1. Overview In this tutorial, we’ll learn how to use Flapdoodle’s embedded MongoDB solution together with Spring Boot to run MongoDB integration tests smoothly. MongoDB is a popular NoSQL document...
View ArticleReflection with Kotlin
1. Introduction Reflection is the name for the ability to inspect, load and interact with classes, fields, and methods at runtime. We can do this even when we don’t know what they are at compile time....
View ArticleEncrypting and Decrypting Files in Java
1. Overview In this tutorial, we’ll take a look on how to encrypt and decrypt a file using existing JDK APIs. 2. Writing a Test First We’ll start by writing our test, TDD style. Since we’re going to...
View ArticleGuide to Resilience4j
1. Overview In this tutorial, we’ll talk about the Resilience4j library. The library helps with implementing resilient systems by managing fault tolerance for remote communications. The library is...
View ArticleHow to Set a Header on a Response with Spring 5
1. Overview In this quick tutorial, we’ll go through different ways of setting a header on a service response, either for non-reactive endpoints or for APIs using Spring’s 5 WebFlux framework. We can...
View ArticleCreate a Symbolic Link with Java
1. Overview In this tutorial, we’ll explore different ways of creating a symbolic link in Java using the NIO.2 API, and explore the differences between hard and soft file links. 2. Hard vs...
View ArticleBuilding a Microservice with Apache Meecrowave
1. Overview In this tutorial, we’ll explore the basic functionality of the Apache Meecrowave framework. Meecrowave is a lightweight microservices framework from Apache, which works very well with CDI,...
View ArticleAn Introduction to the Theory of Big-O Notation
1. Introduction In this article, we’ll give an introduction to the mathematics of big-O notation, as well as show an example of a big-O proof. 2. Formal Definition Definition: f(x) = O(g(x)) means...
View ArticleJava Global Exception Handler
1. Overview In this tutorial, we’ll focus on the Global Exception Handler in Java. We’ll first discuss the basics of the exceptions and the exception handling. Then we’ll have a comprehensive look on...
View ArticleImage to Base64 String Conversion
1. Overview In this quick tutorial, we’re going to cover how to encode image file to a Base64 String, then decode it to retrieve the original image using Apache Common IO and Java 8 native Base64...
View ArticleContext and Servlet Initialization Parameters
1. Overview Servlets are plain Java classes that run in a servlet container. HTTP servlets (a specific type of servlet) are first class citizens in Java web applications. The API of HTTP servlets is...
View ArticleCreate a Java and Kotlin Project with Maven
1. Introduction In this quick tutorial, we’ll see how to set up a Maven project handling both Java and Kotlin sources. We’ll first create a project for Java sources only. We’ll then add the...
View Article