Setting Maximum Memory Size in Java Applications

The heap size of Java applications significantly impacts memory utilization and, consequently, performance aspects such as garbage collection cycles and compressed pointers. Tuning the heap size becomes crucial, particularly when deploying applications within containers or across various hosts. Heap Size Calculations: The -Xmx and -Xms flags control the maximum and initial heap sizes, respectively. However, … Read more

Lombok Tutorial: Code Less, Do More

Lombok is a popular Java library that aims to reduce boilerplate code by providing annotations that generate getters, setters, constructors, and other commonly used methods automatically during the compilation process. In this tutorial we will learn how to use it and which are the pros and cons of this library.

Read more

How to create a List from Java Objects or Records

In Java, working with collections like lists is fundamental. Often, you’ll need to convert objects or records into lists for various purposes. In this tutorial, we’ll explore different approaches to create a List from a property of an Array of Java objects or Records using practical examples.

Read more

Exploring OpenJDK 17 Images: A Comprehensive guide

Java 17 is soon becoming the minimal JDK version for top frameworks such Spring Boot. Selecting the right OpenJDK 17 image for your projects is crucial. This tutorial aims to introduce and test various OpenJDK 17 images available, providing insights into their features and performance.

Read more

Java EnumSet and EnumMap made simple

The EnumMap and EnumSet are specialized implementations in Java that are optimized for working with Enum keys and Enum values, respectively. In this article we will learn how to use them and which are the common use cases. Finally, we will also highlight the differences with the standard Map and Set objects.

Read more

Default parameters for Java methods

Java lacks direct support for default parameter values as seen in some other programming languages. However, there are several techniques and patterns you can utilize to achieve similar functionality. In this tutorial, we’ll explore five different approaches to emulate default parameter values in Java. 1. Method Overloading Method overloading involves creating multiple versions of a … Read more

Fastest way to sort an Array in Java

Sorting arrays efficiently is crucial for optimizing performance in Java applications. With numerous sorting algorithms and built-in methods available, it’s essential to identify the most efficient approach for different scenarios. Let’s delve into a comparative analysis of various sorting methods to determine the fastest way to sort a Java array. Introduction Sorting large arrays efficiently … Read more

Comparing Java Records with Lombok

Java records and Lombok are both tools that aim to reduce boilerplate code in Java, but they have different approaches and use cases. In this article we will compare them to understand which is the perfect use case of each approach. Java Records overview: For example: Lombok Library overview: For example: Please note that, in … Read more

Converting JSON to Java Map using Jackson

This tutorial demonstrates how to convert a JSON string into a Java Map using Jackson’s ObjectMapper. We will show a basic Java main Class to convert a sample JSON String. Then, we will simplify the classpath set up using JBang. Prerequisites Steps: 1. Include Jackson Dependency Make sure to include the Jackson dependencies in your … Read more

How to solve java.lang.NoClassDefFoundError: javax/xml/bind Classes

The java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException error (or other javax.xml.bind classes) typically arises due to missing JAXB API in your Classpath or Runtime. Here’s how to resolve it. Understanding the Issue In Java 9 onwards, the Java EE APIs, including JAXB (Java Architecture for XML Binding), are not included by default. These APIs were traditionally bundled with Java … Read more