List all available features in the Micronaut CLI (mn)

In the Micronaut CLI mn, we can use mn create-app –list-features to list all available features. Table of Contents 1. List All Feature 2. Filter Features 3. Download Source Code 4. References P.S. Tested with Micronaut 4.7.6 1. List All Feature Terminal mn create-app –list-features This will output a categorized list of features like: Terminal …

Read more

Return ZIP file in a Micronaut Controller

In this tutorial, we will create a Micronaut REST API that generates and returns a ZIP file for download. Table of contents 1. Create a Micronaut Controller 2. Unit Testing the Controller 3. Run the Application 4. Download Source Code 5. References Technologies used: Java 21 Micronaut 4.7.6 Maven 3.9.6 1. Create a Micronaut Controller …

Read more

Working Gzip and tar.gz file in Kotlin

This article shows how we can compress, update, and decompress multiple files and folders into a tar.gz file using Kotlin. Table of contents: 1. Gzip vs. Java Zip 2. Add Apache Commons Compress Dependency 3. Compressing Files and Folders into a tar.gz 3.1 file name is too long (>100 bytes) 4. Decompressing a tar.gz File …

Read more

How to Run Startup Code When Micronaut Starts

When building applications with Micronaut, we often need to execute some logic when the application starts. This could include tasks like initializing resources, seeding a database, or logging system information. In this article, we will explore how to run startup code in Micronaut using ApplicationEventListener and @EventListener. Table of contents 1. Implements ApplicationEventListener to Run …

Read more

Return JSON in a Micronaut Controller

In this tutorial, we will learn how to return JSON in a Micronaut controller using simple and practical examples. Table of contents 1. Setting Up the Micronaut Project 2. Returning a JSON Object Define a Data Model What is @Serdeable? Create a Controller Run the Application 3. Returning a List of JSON Objects Run the …

Read more

Micronaut – Loading external yaml or configuration file

In this tutorial, we will explore how to load an external YAML file in a Micronaut application. Table of contents 1. Why Load External Configuration Files? 2. Defining an External YAML File 3. Configuring Micronaut to Load the External YAML File Using Command Line Argument Using Environment Variable 4. Accessing Configuration Values in Micronaut Using …

Read more

Kotlin – Reading Large Files Efficiently

When working with large files in Kotlin, handling them efficiently is crucial to avoid performance issues such as high memory usage and slow processing times. In this article, we explore different approaches to reading large files efficiently in Kotlin and compare them with Java. Table of contents Why Efficient File Reading Matters 1. Read Large …

Read more

Kotlin – Read, Write, Modify, Delete, and List Files

In this article, we will cover how to read, write, modify, delete, and list files in Kotlin and compare them with Java equivalents. Table of contents 1. Reading a File in Kotlin 2. Writing to a File in Kotlin 3. Modifying a File in Kotlin 4. Deleting a File in Kotlin 5. Listing Files in …

Read more

Micronaut @ConfigurationProperties Example

Micronaut provides a powerful way to manage configuration using @ConfigurationProperties. This annotation allows us to bind external configuration properties (such as values from application.yml or application.properties) directly to Java objects. Table of contents 1. Setting Up the Micronaut Project 2. Defining Configuration in application.yml 3. Setting Up the Configuration 4. Injecting the Configuration into a …

Read more

Micronaut @ConfigurationBuilder Example

Micronaut @ConfigurationBuilder allows us to bind configuration files to Java objects using builder pattern. Table of contents 1. Defining Configuration in application.yml 2. Builder Pattern 3. Using @ConfigurationBuilder 4. Injecting the Configured Database 5. Running the Application 6. Unit Tests 7. Download Source Code 8. References Technologies used: Java 21 Micronaut 4.7.6 Maven 3.x 1. …

Read more

Micronaut Tutorials

List of the Micronaut examples, updating still in progress… 1. Getting Started Micronaut Hello World Example Micronaut @ConfigurationProperties Example Micronaut @ConfigurationBuilder Example Micronaut Loading external yaml or configuration file How to Use Dependency Injection in Micronaut Return XML in a Micronaut Controller Return JSON in a Micronaut Controller Return PDF in a Micronaut Controller Return …

Read more

How to Prevent java.lang.OutOfMemoryError in Java

Encountering a java.lang.OutOfMemoryError can be frustrating, but we can take several practical steps to prevent it. In this article, we explain what causes this error, provide real world examples, and discuss effective techniques to manage memory in our Java applications. Table of contents Understanding java.lang.OutOfMemoryError Common Causes and Prevention Techniques 1. Optimize Heap Size 2. …

Read more

Kotlin – Use `object` for Singleton Patterns

In software development, a singleton is a design pattern that ensures a class has only one instance and provides a global access point to it. While implementing singletons in Java requires additional effort, Kotlin makes it simpler using the object keyword. In this article, we will learn how to create a singleton in Kotlin using …

Read more

Top 10 Java Frameworks to Watch in 2025

Java remains one of the most powerful and versatile programming languages, widely used in enterprise applications, web development, microservices, and cloud-based solutions. As technology evolves, new frameworks continue to emerge, improving development efficiency, scalability, and security. In this article, we explore the top 10 Java frameworks to watch in 2025. Java Frameworks 2025 Framework Microservices …

Read more

Return XML in a Micronaut Controller

In this tutorial, we will learn how to return XML responses in a Micronaut application using Jackson XML. Table of contents 1. Setting Up the Micronaut Project Add Jackson XML Dependency 2. Creating the XML Model 3. Creating a Controller to Return XML 4. Running and Testing the Application 5. Writing Unit Tests 6. Download …

Read more

Top 10 Java Application Servers for 2025

Java application servers play a crucial role in deploying and managing Java-based applications. They provide essential features such as security, transaction management, scalability, and performance optimization. In this article, we explore the top 10 Java application servers that developers and enterprises commonly use. Java Application Servers Server Jakarta EE Support Cloud-Native Performance Scalability Use Case …

Read more

Kotlin – Use val Instead of var Wherever Possible

When writing Kotlin code, you should prefer using val instead of var whenever possible. This simple practice enhances code safety, improves performance, and makes your code easier to read and maintain. In this article, we’ll explore why val is preferable, how it compares to var, and provide real-world examples, including a comparison with Java. Table …

Read more

Kotlin – Using ?. and ?.let {} to Avoid Null Checks

One of the most common issues in Java programming is dealing with null values, which can lead to the dreaded NullPointerException (NPE). Kotlin, however, provides built-in features to handle null safety in a more elegant way. Two of the most useful tools for this are ?. (safe call operator) and ?.let {} (scope function). In …

Read more

Zip4j – Java Library for ZIP Files (With Examples)

In this tutorial, we show how to use the Zip4j library for handling ZIP files like adding files and directories, updating existing ZIPs, password protection, and encryption. Table of Content: 1. Adding Zip4j Dependency 2. Creating a ZIP File and Adding Files 3. Adding a Directory to ZIP 4. Adding Files to an Existing ZIP …

Read more

Java – Swap Two Variables Without a Temp Variable

Swapping two variables is a common task in programming. Traditionally, we use a temporary variable to hold one value while swapping, but Java allows us to swap two variables without using a temp variable. In this tutorial, we will explore different ways to achieve this in Java with real-world examples. Table of contents: 1. Swapping …

Read more

How to Change the Default Micronaut Server Port

By default, a Micronaut application runs on port 8080. In this guide, we will explore multiple ways to change the default Micronaut server port. Table of Contents: 1. Changing the Server Port in application.yml 2. Changing the Server Port in application.properties 3. Setting the Port Using Environment Variables 4. Setting a Random Port 5. Download …

Read more

Pretty Print JSON with JSON.simple

This article shows how to pretty print JSON with JSON.simple. Table of contents: 1. Setup JSON.simple 2. Default Compact Print JSON 3. Pretty Print JSON with JSON.simple 4. Write Pretty Print JSON to a File 5. Download Source Code 6. References P.S Tested with json-simple 4.0.1 1. Setup JSON.simple pom.xml <dependency> <groupId>com.github.cliftonlabs</groupId> <artifactId>json-simple</artifactId> <version>4.0.1</version> </dependency> …

Read more

How to exclude fields in Gson

In GSON, we can use the transient keyword, ExclusionStrategy, and @Expose to exclude fields during the JSON serialization or deserialization process. Table of contents: 1. Setup Google Gson 2. Using the "transient" Keyword 3. Using the "ExclusionStrategy" 4. Using the "ExclusionStrategy" and custom annotation 5. Using the @Expose annotation 6. Download Source Code 7. References …

Read more

Jackson Custom Serializer and Deserializer Examples

This article shows how to create a Jackson custom serializer and deserializer to parse JSON data that contains a LocalDate type. The Jackson custom serializer or deserializer is useful when we want to process a specific format that is not the default. Table of contents: 1. Setup Jackson 2. Jackson Custom Serializer for LocalDate 3. …

Read more