How to Compile Java to WASM (Web Assembly)
1. Overview In the fast-paced world of web development, the introduction of WASM (WebAssembly) has presented developers with new possibilities. It allows them to leverage the speed and adaptability of...
View ArticleDisable Logging From a Specific Class in Logback
1. Overview Logging is a critical component of any application, offering insights into its behavior and health. However, excessive logging can clutter output and obscure useful information, especially...
View ArticleFault Tolerance in Java Using Failsafe
1. Introduction In this article, we’re going to explore the Failsafe library and see how it can be incorporated into our code to make it more resilient to failure cases. 2. What Is Fault Tolerance? No...
View ArticleAdd Global Exception Interceptor in gRPC Server
1. Overview In this tutorial, we’ll examine the role of interceptors in gRPC server applications to handle global exceptions. Interceptors can validate or manipulate the request before it reaches the...
View ArticleMocking Protected Method in Java
1. Overview Mocking protected method in Java is similar to mocking a public one, with one caveat: visibility of this method in the test class. We have visibility of protected methods of class A from...
View ArticleDifference Between Optional.of() and Optional.ofNullable() in Java
1. Overview In Java, a reference may or may not point to an object in memory. In other words, a reference can be null. As a result, this gives rise to the possibility of a NullPointerException being...
View ArticleHow to Check if Optional Contains Value Equal to T Object
1. Overview Optional is a class that was introduced in Java 8 as part of the java.util package. It serves as a container that may or may not contain a non-null value. Optional can help us handle null...
View ArticleLooking for a Backend Java/Spring Developer with Integration Experience...
About Us Baeldung is a learning and media company with a focus on the programming space. We’re a flexible, entirely remote team. Description We’re looking for a Java developer with integration...
View ArticleFinding Minimum and Maximum in a 2D Array
1. Overview In this tutorial, we’ll discuss two techniques for finding the minimum and maximum values within a 2D array using Java. A 2D array is an arrangement of elements structured like a grid. It’s...
View ArticleFinding the Next Higher Number With the Same Digits
1. Introduction In this tutorial, we’ll learn how to find the next higher number with the same set of digits as the original number in Java. This problem can be solved by using the concept of...
View ArticleDifference Between Iterator.forEachRemaining() and Iterable.forEach()
1. Introduction The Iterator and Iterable interfaces are fundamental constructs for working with collections in Java. Practically, each interface provides methods for traversing elements, but they have...
View ArticleGet the Indices of an Array After Sorting in Java
1. Introduction Sorting an array is a common operation in Java, but sometimes, we also need to know the original indices of the elements after sorting. This information can be crucial for certain...
View ArticleHow to Convert XML to PDF
1. Overview Java provides several libraries and APIs for working with XML and PDF documents. Converting XML to PDF in Java involves parsing the XML data, applying styles and formatting, and generating...
View ArticleConvert Between CLOB and String in Java
1. Introduction When working with databases in Java, handling large text data is a common task. Besides, the Character Large Object (CLOB) type allows databases to store extensive text data. Moreover,...
View ArticleClear Managed Entities in JPA/Hibernate
1. Overview In this tutorial, we’ll review how entities are managed in JPA and then explore a scenario where the persistence context may not return fresh data due to external changes. 2. Persistence...
View ArticleMonitor a Spring Boot App Using Prometheus
1. Overview In the demanding world of software development, ensuring that applications perform optimally and reliably once deployed in production environments is not just preferable — it’s essential....
View ArticleUsing @Autowired and @InjectMocks in Spring Boot Tests
1. Overview In this tutorial, we’ll explore the usage of Spring Boot’s @Autowired and Mockito’s @InjectMocks while injecting dependencies in Spring Boot tests. We’ll go over the use cases that require...
View ArticleComparison Between Flux.map() and Flux.doOnNext()
1. Overview In the Reactor library, the Flux.map() and Flux.doOnNext() operators play different roles in working with stream data elements. The Flux.map() operator helps to transform each element...
View ArticleMerge Multiple PDF Files Into a Single PDF Using Java
1. Introduction In the modern business and document management workflow, the ability to merge multiple PDF files into a single PDF document is a common requirement. Common use cases include...
View ArticleMap LocalDateTime to Instant in MapStruct
1. Overview When working with dates and times in Java, we often encounter different formats, such as LocalDateTime and Instant. While LocalDateTime represents a date-time without a time zone, Instant...
View Article