Spring Boot with Multiple SQL Import Files
1. Overview Spring Boot allows us to import sample data into our database – mainly to prepare data for integration tests. Out of the box, there are two possibilities. We can use import.sql (Hibernate...
View ArticleIterating Backward Through a List
1. Overview In this quick tutorial, we’ll learn about various ways in which we can iterate backward through a list in Java. 2. Iterator in Java An Iterator is an interface in the Java Collections...
View ArticleUsing Spring @ResponseStatus to Set HTTP Status Code
1. Introduction In Spring MVC, we have many ways to set the status code of an HTTP response. In this short tutorial, we will see the most straightforward way: using the @ResponseStatus annotation. 2....
View ArticleUsing Spring ResponseEntity to Manipulate the HTTP Response
1. Introduction Using Spring, we usually have many ways to achieve the same goal, including fine-tuning HTTP responses. In this short tutorial, we’ll see how to set the body, status, and headers of an...
View ArticleInterpreter Design Pattern in Java
1. Overview In this tutorial, we’ll introduce one of the behavioral GoF design patterns – the Interpreter. At first, we’ll give an overview of its purpose and explain the problem it tries to solve....
View ArticleQuick Use of FilenameFilter
1. Introduction Java has had functional interfaces before the addition of the informative annotation, @FunctionalInterface. FilenameFilter is one such interface. We’ll be taking a brief look at its...
View ArticleIntroduction to GWT
1. Introduction GWT or Google Web Toolkit is a framework for building high-performance web applications in Java. In this tutorial, we’re going to focus on and cover some of its key capabilities and...
View ArticleLogging in Spring Boot
1. Overview In this short tutorial, we’re going to explore the main logging options available in Spring Boot. Deeper information about Logback is available in A Guide To Logback, while Log4j2 is...
View ArticleUsing AWS Lambda with API Gateway
1. Overview AWS Lambda is a serverless computing service provided by Amazon Web Services. In two previous articles, we discussed how to create an AWS Lambda function using Java, as well as how to...
View ArticleConsole 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 Article