Partner – Microsoft – NPI EA (cat = Baeldung)
announcement - icon

Azure Container Apps is a fully managed serverless container service that enables you to build and deploy modern, cloud-native Java applications and microservices at scale. It offers a simplified developer experience while providing the flexibility and portability of containers.

Of course, Azure Container Apps has really solid support for our ecosystem, from a number of build options, managed Java components, native metrics, dynamic logger, and quite a bit more.

To learn more about Java features on Azure Container Apps, visit the documentation page.

You can also ask questions and leave feedback on the Azure Container Apps GitHub page.

Partner – Microsoft – NPI EA (cat= Spring Boot)
announcement - icon

Azure Container Apps is a fully managed serverless container service that enables you to build and deploy modern, cloud-native Java applications and microservices at scale. It offers a simplified developer experience while providing the flexibility and portability of containers.

Of course, Azure Container Apps has really solid support for our ecosystem, from a number of build options, managed Java components, native metrics, dynamic logger, and quite a bit more.

To learn more about Java features on Azure Container Apps, you can get started over on the documentation page.

And, you can also ask questions and leave feedback on the Azure Container Apps GitHub page.

Partner – Orkes – NPI EA (cat=Spring)
announcement - icon

Modern software architecture is often broken. Slow delivery leads to missed opportunities, innovation is stalled due to architectural complexities, and engineering resources are exceedingly expensive.

Orkes is the leading workflow orchestration platform built to enable teams to transform the way they develop, connect, and deploy applications, microservices, AI agents, and more.

With Orkes Conductor managed through Orkes Cloud, developers can focus on building mission critical applications without worrying about infrastructure maintenance to meet goals and, simply put, taking new products live faster and reducing total cost of ownership.

Try a 14-Day Free Trial of Orkes Conductor today.

Partner – Orkes – NPI EA (tag=Microservices)
announcement - icon

Modern software architecture is often broken. Slow delivery leads to missed opportunities, innovation is stalled due to architectural complexities, and engineering resources are exceedingly expensive.

Orkes is the leading workflow orchestration platform built to enable teams to transform the way they develop, connect, and deploy applications, microservices, AI agents, and more.

With Orkes Conductor managed through Orkes Cloud, developers can focus on building mission critical applications without worrying about infrastructure maintenance to meet goals and, simply put, taking new products live faster and reducing total cost of ownership.

Try a 14-Day Free Trial of Orkes Conductor today.

eBook – Guide Spring Cloud – NPI EA (cat=Spring Cloud)
announcement - icon

Let's get started with a Microservice Architecture with Spring Cloud:

>> Join Pro and download the eBook

eBook – Mockito – NPI EA (tag = Mockito)
announcement - icon

Mocking is an essential part of unit testing, and the Mockito library makes it easy to write clean and intuitive unit tests for your Java code.

Get started with mocking and improve your application tests using our Mockito guide:

Download the eBook

eBook – Java Concurrency – NPI EA (cat=Java Concurrency)
announcement - icon

Handling concurrency in an application can be a tricky process with many potential pitfalls. A solid grasp of the fundamentals will go a long way to help minimize these issues.

Get started with understanding multi-threaded applications with our Java Concurrency guide:

>> Download the eBook

eBook – Reactive – NPI EA (cat=Reactive)
announcement - icon

Spring 5 added support for reactive programming with the Spring WebFlux module, which has been improved upon ever since. Get started with the Reactor project basics and reactive programming in Spring Boot:

>> Join Pro and download the eBook

eBook – Java Streams – NPI EA (cat=Java Streams)
announcement - icon

Since its introduction in Java 8, the Stream API has become a staple of Java development. The basic operations like iterating, filtering, mapping sequences of elements are deceptively simple to use.

But these can also be overused and fall into some common pitfalls.

To get a better understanding on how Streams work and how to combine them with other language features, check out our guide to Java Streams:

>> Join Pro and download the eBook

eBook – Jackson – NPI EA (cat=Jackson)
announcement - icon

Do JSON right with Jackson

Download the E-book

eBook – HTTP Client – NPI EA (cat=Http Client-Side)
announcement - icon

Get the most out of the Apache HTTP Client

Download the E-book

eBook – Maven – NPI EA (cat = Maven)
announcement - icon

Get Started with Apache Maven:

Download the E-book

eBook – Persistence – NPI EA (cat=Persistence)
announcement - icon

Working on getting your persistence layer right with Spring?

Explore the eBook

eBook – RwS – NPI EA (cat=Spring MVC)
announcement - icon

Building a REST API with Spring?

Download the E-book

Course – LS – NPI EA (cat=Jackson)
announcement - icon

Get started with Spring and Spring Boot, through the Learn Spring course:

>> LEARN SPRING
Course – RWSB – NPI EA (cat=REST)
announcement - icon

Explore Spring Boot 3 and Spring 6 in-depth through building a full REST API with the framework:

>> The New “REST With Spring Boot”

Course – LSS – NPI EA (cat=Spring Security)
announcement - icon

Yes, Spring Security can be complex, from the more advanced functionality within the Core to the deep OAuth support in the framework.

I built the security material as two full courses - Core and OAuth, to get practical with these more complex scenarios. We explore when and how to use each feature and code through it on the backing project.

You can explore the course here:

>> Learn Spring Security

Course – LSD – NPI EA (tag=Spring Data JPA)
announcement - icon

Spring Data JPA is a great way to handle the complexity of JPA with the powerful simplicity of Spring Boot.

Get started with Spring Data JPA through the guided reference course:

>> CHECK OUT THE COURSE

Partner – MongoDB – NPI EA (tag=MongoDB)
announcement - icon

Traditional keyword-based search methods rely on exact word matches, often leading to irrelevant results depending on the user's phrasing.

By comparison, using a vector store allows us to represent the data as vector embeddings, based on meaningful relationships. We can then compare the meaning of the user’s query to the stored content, and retrieve more relevant, context-aware results.

Explore how to build an intelligent chatbot using MongoDB Atlas, Langchain4j and Spring Boot:

>> Building an AI Chatbot in Java With Langchain4j and MongoDB Atlas

Partner – LambdaTest – NPI EA (cat=Testing)
announcement - icon

Accessibility testing is a crucial aspect to ensure that your application is usable for everyone and meets accessibility standards that are required in many countries.

By automating these tests, teams can quickly detect issues related to screen reader compatibility, keyboard navigation, color contrast, and other aspects that could pose a barrier to using the software effectively for people with disabilities.

Learn how to automate accessibility testing with Selenium and the LambdaTest cloud-based testing platform that lets developers and testers perform accessibility automation on over 3000+ real environments:

Automated Accessibility Testing With Selenium

1. Overview

The Java Virtual Machine (JVM) is a powerful engine that powers Java applications. It executes compiled .class files, manages memory, and boosts performance using the techniques like Just-in-Time (JIT) compilation and Garbage Collection.

The JVM is incredibly flexible. With the right arguments, we can tweak its behavior to boost performance, troubleshoot problems, and try out experimental features with ease. In this tutorial, we’ll explore the different argument prefixes that we can use to configure the JVM.

2. What Are JVM Arguments?

JVM Arguments are special command-line options that can change the behavior of the JVM. These parameters control things like memory settings, performance tuning, enabling debugging and monitoring, garbage collection configuration, and experimental features.

We can specify these arguments when we start the JVM, for example:

java -Xmx512m -Denv=prod -verbose:gc -XX:+UseG1GC -jar App.jar

In the above command, we’ve used multiple different prefixes. Each prefix tells the JVM what kind of configuration is being passed.

  • -Xmx512m – sets the maximum heap size to 512 MB. (Non-standard option)
  • -Denv=prod – defines a system property named env with value prod. (System Property)
  • -verbose:gc – enables garbage collection logging. (Standard option)
  • -XX:+UseG1GC – tells JVM to use the G1 Garbage Collector. (Advanced option)

Let’s explore each prefix in detail.

3. Different JVM Argument Prefixes

3.1. System Properties (-D)

System properties are typically used to configure JVM-specific parameters, such as file encoding, user directories, JVM version, and other Java-specific configurations.

We can define key-value pairs known as System properties by passing them using the -D command-line argument, like below:

java -Denv=prod -jar App.jar

In the -D argument prefix, the letter D stands for Define. Java didn’t use other letters to avoid confusion. It’s short, simple, and easy to remember. It tells us that we’re defining a property.

3.2. Standard Options ()

Java standard options are documented settings that we can use with any JVM to control its basic behavior. All JVM implementations support the standard option. These options help us manage how the JVM launches and runs Java programs.

For example, we can use -classpath to set the classpath, and -version to check the JVM version:

java -version

It prints:

openjdk version "17.0.14" 2025-01-21 LTS
OpenJDK Runtime Environment Corretto-17.0.14.7.1 (build 17.0.14+7-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.14.7.1 (build 17.0.14+7-LTS, mixed mode, sharing)

We can run the java command in a terminal to see a list of standard options:

Usage: java [options] <mainclass> [args...]
           (to execute a class)
   or  java [options] -jar <jarfile> [args...]
           (to execute a jar file)

 where options include:

    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
    --class-path <class search path of directories and zip/jar files>
                  A : separated list of directories, JAR archives,
                  and ZIP archives to search for class files.
To specify an argument for a long option, you can use --<name>=<value> or
--<name> <value>.

3.3. Non-Standard Options (-X)

We use -X options to access non-standard JVM features that often control memory and debugging behavior. These options can vary across different JVM implementations like OpenJDK, HotSpot, or Microsoft’s JVM. For example, a JVM from Red Hat may support -X options different from Microsoft’s.

 We can list all the non-standard options using the following command:

java -X

The output will depend on the JVM implementation:

    -Xbatch           disable background compilation
    -Xbootclasspath/a:<directories and zip/jar files separated by :>
                      append to end of bootstrap class path
    -Xcheck:jni       perform additional checks for JNI functions
    -Xcomp            forces compilation of methods on first invocation
    -Xdebug           does nothing. Provided for backward compatibility.
[...]

These options are useful for general-purpose tuning, but we should use them with caution because they’re implementation-specific and subject to change without notice.

3.4. Advanced Options (-XX)

We can use advanced JVM options to enable low-level, often experimental features. These options start with -XX. We can categorize these options into two types: boolean options, which let us enable or disable specific features, and value options, which allow us to set custom values.

Some of these options remain stable across versions, but others can change, become deprecated, or even be removed in future JVM releases. Since not all JVM implementations support every advanced option, we must use them carefully and stay updated as the JVM evolves.

Let’s take a look at the command that uses advanced options to tune the JVM’s garbage collection behavior for better responsiveness:

java -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -jar App.jar

Here, we first instruct the JVM to use the G1 Garbage Collector, then ask it to aim for GC pauses under 200 ms. This is a soft goal, meaning the JVM will try to meet it, but doesn’t guarantee it.

4. JVM Execution Modes

Let’s take a look at different JVM execution modes we can use to control JIT compilation, which compiles Java bytecode into native machine code at runtime and optimizes it based on runtime profiling.

We’ll use a Benchmark.java program that fills a HashMap with 1 million key-value pairs and retrieves all values to ensure correctness and measure performance.

public class Benchmark {
    private static final int NUM_ENTRIES = 1_000_000;

    public static void main(String[] args) {
        Benchmark benchmark = new Benchmark();
        benchmark.run();
    }

    public void run() {
        HashMap<Integer, String> map = new HashMap<>();

        // Fill the HashMap
        long startPut = System.nanoTime();
        for (int i = 0; i < NUM_ENTRIES; i++) {
            map.put(i, "Value" + i);
        }
        long endPut = System.nanoTime();
        System.out.println("Time to put: " + (endPut - startPut) / 1_000_000 + " ms");

        // Retrieve from the HashMap
        long startGet = System.nanoTime();
        for (int i = 0; i < NUM_ENTRIES; i++) {
            String value = map.get(i);
            if (value == null) {
                System.err.println("Missing key: " + i);
            }
        }
        long endGet = System.nanoTime();
        System.out.println("Time to get: " + (endGet - startGet) / 1_000_000 + " ms");
    }
}

4.1. -Xint – Interpreted Mode Only

The -Xint flag forces the JVM to interpret all bytecode instead of compiling it. This disables the JIT compilation entirely. As a result, executions slow down severely.

This flag helps us isolate issues related to JIT behavior during debugging and compare the performance impact of JIT compilation versus pure interpretation.

Let’s see the performance of interpreted execution mode:

java -server -showversion -Xint Benchmark
openjdk version "17.0.14" 2025-01-21 LTS
OpenJDK Runtime Environment Corretto-17.0.14.7.1 (build 17.0.14+7-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.14.7.1 (build 17.0.14+7-LTS, interpreted mode, sharing)
Time to put: 1532 ms
Time to get: 261 ms

4.2. -Xcomp – Compile-Only Mode

The -Xcomp flag forces the JVM to compile all methods at first use, rather than waiting to identify hot methods. This sounds nice because it completely avoids the slow interpreter.

However, it often causes slower startup due to aggressive compilation, though it may deliver long-term performance gains.

Let’s see the performance of the compile execution mode:

java -server -showversion -Xcomp Benchmark
openjdk version "17.0.14" 2025-01-21 LTS
OpenJDK Runtime Environment Corretto-17.0.14.7.1 (build 17.0.14+7-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.14.7.1 (build 17.0.14+7-LTS, compiled mode, sharing)
Time to put: 1167 ms
Time to get: 10 ms

4.3. -Xmixed – Default Mode

The mixed mode starts by interpreting the code and then compiles the hot methods using the JIT compiler. This approach helps us balance startup time with long-term performance, giving us the benefits of both worlds.

The recent version of HotSpot uses mixed mode by default, so we no longer need to specify this flag manually. Let’s take a look at its performance:

java -server -showversion Benchmark
openjdk version "17.0.14" 2025-01-21 LTS
OpenJDK Runtime Environment Corretto-17.0.14.7.1 (build 17.0.14+7-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.14.7.1 (build 17.0.14+7-LTS, mixed mode, sharing)
Time to put: 75 ms
Time to get: 12 ms

The output shows that the default mixed mode offers the best balance between startup time and runtime performance. Interpreted mode -Xint is significantly slower and mainly used for debugging or analysis. Compiled mode -Xcomp reduces the execution time for hot paths but comes with a higher startup cost.

4.4. -Xverify – Verification Control

When Java code is compiled, it’s turned into bytecode, which is run by the JVM. The JVM performs bytecode verification before execution to ensure that the code complies with the JVM specification, uses the stack correctly, accesses variables safely, and maintains proper control flow. This step helps prevent crashes and security risks, particularly when running untrusted or third-party code.

The -Xverify option allows us to control when and whether the bytecode verification happens. The -Xverify:all option is the default behavior. It verifies all classes when the JVM loads them. This ensures both safety and correctness during execution.

The -Xverify:none option skips class verification during loading. It may slightly improve the startup time, but it reduces safety and can be risky:

java -Xverify:none -cp app.jar com.baeldung.Main

We can use VisualVM and Java Management Extensions (JMX) for remote monitoring of Java applications.

5. Conclusion

In this tutorial, we explored various JVM argument prefixes. JVM execution modes also fall under non-standard argument prefixes. The mixed mode provides the most efficient and stable behavior for general application use. Using the right JVM arguments can enhance an application’s performance, improve stability, and simplify debugging.

The decision to set specific JVM arguments depends on several factors, including the complexity of the application and its performance requirements. Using commonly used JVM arguments can enhance our application’s performance and functionality.

Baeldung Pro – NPI EA (cat = Baeldung)
announcement - icon

Baeldung Pro comes with both absolutely No-Ads as well as finally with Dark Mode, for a clean learning experience:

>> Explore a clean Baeldung

Once the early-adopter seats are all used, the price will go up and stay at $33/year.

Partner – Microsoft – NPI EA (cat = Baeldung)
announcement - icon

Azure Container Apps is a fully managed serverless container service that enables you to build and deploy modern, cloud-native Java applications and microservices at scale. It offers a simplified developer experience while providing the flexibility and portability of containers.

Of course, Azure Container Apps has really solid support for our ecosystem, from a number of build options, managed Java components, native metrics, dynamic logger, and quite a bit more.

To learn more about Java features on Azure Container Apps, visit the documentation page.

You can also ask questions and leave feedback on the Azure Container Apps GitHub page.

Partner – Microsoft – NPI EA (cat = Spring Boot)
announcement - icon

Azure Container Apps is a fully managed serverless container service that enables you to build and deploy modern, cloud-native Java applications and microservices at scale. It offers a simplified developer experience while providing the flexibility and portability of containers.

Of course, Azure Container Apps has really solid support for our ecosystem, from a number of build options, managed Java components, native metrics, dynamic logger, and quite a bit more.

To learn more about Java features on Azure Container Apps, visit the documentation page.

You can also ask questions and leave feedback on the Azure Container Apps GitHub page.

Partner – Orkes – NPI EA (cat = Spring)
announcement - icon

Modern software architecture is often broken. Slow delivery leads to missed opportunities, innovation is stalled due to architectural complexities, and engineering resources are exceedingly expensive.

Orkes is the leading workflow orchestration platform built to enable teams to transform the way they develop, connect, and deploy applications, microservices, AI agents, and more.

With Orkes Conductor managed through Orkes Cloud, developers can focus on building mission critical applications without worrying about infrastructure maintenance to meet goals and, simply put, taking new products live faster and reducing total cost of ownership.

Try a 14-Day Free Trial of Orkes Conductor today.

Partner – Orkes – NPI EA (tag = Microservices)
announcement - icon

Modern software architecture is often broken. Slow delivery leads to missed opportunities, innovation is stalled due to architectural complexities, and engineering resources are exceedingly expensive.

Orkes is the leading workflow orchestration platform built to enable teams to transform the way they develop, connect, and deploy applications, microservices, AI agents, and more.

With Orkes Conductor managed through Orkes Cloud, developers can focus on building mission critical applications without worrying about infrastructure maintenance to meet goals and, simply put, taking new products live faster and reducing total cost of ownership.

Try a 14-Day Free Trial of Orkes Conductor today.

eBook – HTTP Client – NPI EA (cat=HTTP Client-Side)
announcement - icon

The Apache HTTP Client is a very robust library, suitable for both simple and advanced use cases when testing HTTP endpoints. Check out our guide covering basic request and response handling, as well as security, cookies, timeouts, and more:

>> Download the eBook

eBook – Java Concurrency – NPI EA (cat=Java Concurrency)
announcement - icon

Handling concurrency in an application can be a tricky process with many potential pitfalls. A solid grasp of the fundamentals will go a long way to help minimize these issues.

Get started with understanding multi-threaded applications with our Java Concurrency guide:

>> Download the eBook

eBook – Java Streams – NPI EA (cat=Java Streams)
announcement - icon

Since its introduction in Java 8, the Stream API has become a staple of Java development. The basic operations like iterating, filtering, mapping sequences of elements are deceptively simple to use.

But these can also be overused and fall into some common pitfalls.

To get a better understanding on how Streams work and how to combine them with other language features, check out our guide to Java Streams:

>> Join Pro and download the eBook

eBook – Persistence – NPI EA (cat=Persistence)
announcement - icon

Working on getting your persistence layer right with Spring?

Explore the eBook

Partner – MongoDB – NPI EA (tag=MongoDB)
announcement - icon

Traditional keyword-based search methods rely on exact word matches, often leading to irrelevant results depending on the user's phrasing.

By comparison, using a vector store allows us to represent the data as vector embeddings, based on meaningful relationships. We can then compare the meaning of the user’s query to the stored content, and retrieve more relevant, context-aware results.

Explore how to build an intelligent chatbot using MongoDB Atlas, Langchain4j and Spring Boot:

>> Building an AI Chatbot in Java With Langchain4j and MongoDB Atlas

Course – LS – NPI EA (cat=REST)

announcement - icon

Get started with Spring Boot and with core Spring, through the Learn Spring course:

>> CHECK OUT THE COURSE

eBook Jackson – NPI EA – 3 (cat = Jackson)