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

Azure Container Apps is a fully managed serverless containerservice that enables you tobuild and deploy modern,cloud-native Java applications and microservices at scale. Itoffers a simplified developer experience while providing theflexibility and portability of containers.

Of course, Azure Container Apps has really solid support for ourecosystem, 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, visitthedocumentation page.

You can also ask questions and leave feedback on the AzureContainer AppsGitHub page.

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

Azure Container Apps is a fully managed serverless containerservice that enables you tobuild and deploy modern,cloud-native Java applications and microservices at scale. Itoffers a simplified developer experience while providing theflexibility and portability of containers.

Of course, Azure Container Apps has really solid support for ourecosystem, 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, youcan get started over on thedocumentation page.

And, you can also ask questions and leave feedback on the AzureContainer AppsGitHub page.

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

Modern software architecture is often broken. Slow deliveryleads to missed opportunities, innovation is stalled due toarchitectural complexities, and engineering resources areexceedingly expensive.

Orkes is the leading workflow orchestration platformbuilt 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 canfocus on building mission critical applications without worryingabout infrastructure maintenance to meet goals and, simply put,taking new products live faster and reducing total cost ofownership.

Try a14-Day FreeTrial of Orkes Conductor today.

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

Modern software architecture is often broken. Slow deliveryleads to missed opportunities, innovation is stalled due toarchitectural complexities, and engineering resources areexceedingly expensive.

Orkes is the leading workflow orchestration platformbuilt 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 canfocus on building mission critical applications without worryingabout infrastructure maintenance to meet goals and, simply put,taking new products live faster and reducing total cost ofownership.

Try a14-DayFree 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 SpringCloud:

>> Join Pro and download theeBook

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

Mocking is an essential part of unit testing, and the Mockitolibrary makes it easy to writeclean and intuitive unittests for your Java code.

Get started with mocking and improve your application testsusing ourMockito guide:

Download theeBook

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

Handling concurrency in an application can be a tricky processwith manypotential pitfalls. A solid grasp of thefundamentals will go a long way to help minimize these issues.

Get started with understanding multi-threaded applications withourJava Concurrency guide:

>>Download the eBook

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

Spring 5 added support for reactive programming with the SpringWebFlux module, which has been improved upon ever since. Getstarted with the Reactor project basics andreactive programmingin Spring Boot:

>> Join Pro anddownload the eBook

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

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

But these can also be overused and fall into some commonpitfalls.

Toget a better understanding on how Streams work and howto combine them with other language features, check out our guideto Java Streams:

>> Join Proand download the eBook

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

Do JSON right with Jackson

Download theE-book

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

Get the most out of the Apache HTTP Client

Download theE-book

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

Get Started with Apache Maven:

Download theE-book

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

Working on getting your persistence layer right with Spring?

Explore theeBook

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 theLearnSpring course:

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

Explore Spring Boot 3 and Spring 6 in-depth through building afullREST 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 advancedfunctionality within the Core to the deep OAuth support in theframework.

I built the security material astwo full courses - Core andOAuth, to get practical with these more complex scenarios. Weexplore when and how to use each feature andcode through it onthe backing project.

You can explore the course here:

>> Learn SpringSecurity

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

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

Get started with Spring Data JPA through the guided referencecourse:

>> CHECK OUT THECOURSE

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

End-to-end testing is a very useful method to make sure thatyour application works as intended. This highlightsissues inthe overall functionality of the software, that the unit andintegration test stages may miss.

Playwright is an easy-to-use, but powerful tool thatautomates end-to-end testing, and supports all modernbrowsers and platforms.

Whencoupled with LambdaTest (an AI-powered cloud-basedtest execution platform) it can be further scaled to run thePlaywright scripts in parallel across 3000+ browser and devicecombinations:

>>Automated End-to-End Testing With Playwright

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

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

By comparison, using a vector store allows us to represent thedata as vector embeddings, based on meaningful relationships. Wecan then compare the meaning of the user’s query to the storedcontent, andretrieve more relevant, context-awareresults.

Explore how tobuild an intelligent chatbot using MongoDBAtlas, Langchain4j and Spring Boot:

>>Building an AI Chatbot in Java With Langchain4j and MongoDBAtlas

1. Overview

In this quick tutorial, we’ll explore the most well-known options that we can use to configure the Java Virtual Machine.

2. Explicit Heap Memory – Xms and Xmx Options

One of the most common performance-related practices is to initialize the heap memory as per the application requirements.

That’s why we should specify minimal and maximal heap size. We can use the below parameters to achieve this:

-Xms<heap size>[unit] -Xmx<heap size>[unit]

Here,unit denotes the unit in which we’ll initialize the memory (indicated byheap size). We can mark units as‘g’ for GB,‘m’ for MB, and‘k’ for KB.

For example, if we want to assign minimum 2 GB and maximum 5 GB to JVM, we need to write:

-Xms2G -Xmx5G

Starting with Java 8, the size ofMetaspace isn’t defined. Once it reaches the global limit, JVM automatically increases it. However, to overcome any unnecessary instability, we can setMetaspace size with:

-XX:MaxMetaspaceSize=<metaspace size>[unit]

Here,metaspace size denotes the amount of memory we want to assign toMetaspace.

As per theOracle guidelines, after total available memory, the second most influential factor is the proportion of the heap reserved for the Young Generation. By default, the minimum size of the YG is 1310 MB, and maximum size isunlimited.

We can assign them explicitly:

-XX:NewSize=<young size>[unit] -XX:MaxNewSize=<young size>[unit]

3. Garbage Collection

For better stability of the application, choosing the rightGarbage Collection algorithm is critical.

JVM has four types ofGC implementations:

  • Serial Garbage Collector
  • Parallel Garbage Collector
  • CMS Garbage Collector
  • G1 Garbage Collector

We can declare these implementations with the below parameters:

-XX:+UseSerialGC-XX:+UseParallelGC-XX:+USeParNewGC-XX:+UseG1GC

And we can find more details on Garbage Collection implementationshere.

4. GC Logging

To strictly monitor the application health, we should always check the JVM’sGarbage Collection performance. The easiest way to do this is to log theGC activity in human readable format.

Using the following parameters, we can log theGC activity:

-XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=< number of log files > -XX:GCLogFileSize=< file size >[ unit ]-Xloggc:/path/to/gc.log

UseGCLogFileRotation specifies the log file rolling policy, much like log4j, s4lj, etc.NumberOfGCLogFiles denotes the max number of log files we can write for a single application life cycle.GCLogFileSize specifies the max size of the file. Finally,loggc denotes its location.

One point to note here is that there are two more JVM parameters available (-XX:+PrintGCTimeStamps and-XX:+PrintGCDateStamps) that we can use to print date-wise timestamps in theGC log.

For example, if we want to assign a maximum of 100GC log files, each having a maximum size of 50 MB, and we want to store them in the ‘/home/user/log/’location, we can use the below syntax:

-XX:+UseGCLogFileRotation  -XX:NumberOfGCLogFiles=10-XX:GCLogFileSize=50M -Xloggc:/home/user/log/gc.log

However, the problem is that one additional daemon thread is always used for monitoring system time in the background. This behavior may create some performance bottleneck, which is why it’s better to not play with this parameter in production.

5. Handling out of Memory

It’s very common for a large application to face anout of memory error, which in turn results in an application crash. It’s a very critical scenario, and very hard to replicate to troubleshoot the issue.

That’s why JVM comes with some parameters to dump heap memory into a physical file that we can use later to find leaks:

-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=./java_pid<pid>.hprof-XX:OnOutOfMemoryError="< cmd args >;< cmd args >" -XX:+UseGCOverheadLimit

A couple of points to note here:

  • HeapDumpOnOutOfMemoryError instructs the JVM to dump heap into a physical file in case ofOutOfMemoryError.
  • HeapDumpPath denotes the path where the file will be written. Any filename can be given; however, if JVM finds a<pid> tag in the name, the process id of the current process causing the out of memory error will be appended to the file name with.hprof format.
  • OnOutOfMemoryError is used to issue emergency commands that will be executed in case of an out of memory error. We should use proper commands in the space of cmd args. For example, if we want to restart the server as soon as an out of memory occurs, we can set the parameter:
-XX:OnOutOfMemoryError="shutdown -r"
  • UseGCOverheadLimit is a policy that limits the proportion of the VM’s time that’s spent in GC before anOutOfMemory error is thrown.

6. 32/64 Bit

In an OS environment where we’ve installed both 32 and 64-bit packages, the JVM automatically chooses the 32-bit environmental packages.

If we want to set the environment to 64 bit manually, we can do so using the below parameter:

-d<OS bit>

OS bit can be either32 or64. We can find more information about thishere.

7. Misc

  • -server: enables “Server Hotspot VM.” We use this parameter by default in 64 bit JVM.
  • -XX:+UseStringDeduplication:Java 8u20 has introduced this JVM parameter for reducing the unnecessary use of memory by creating too many instances of the sameString. This optimizes the heap memory by reducing duplicateString values to a single global char[] array.
  • -XX:+UseLWPSynchronization: sets aLWP (Light Weight Process) based synchronization policy instead of thread-based synchronization.
  • -XX:LargePageSizeInBytes:sets the large page size used for the Java heap. It takes the argument in GB/MB/KB. With larger page sizes, we can make better use of virtual memory hardware resources; however, this may cause larger space sizes for thePermGen, which in turn can force us to reduce the size of the Java heap space.
  • -XX:MaxHeapFreeRatio: sets the maximum percentage of heap free afterGC to avoid shrinking
  • -XX:MinHeapFreeRatio: sets the minimum percentage of heap free afterGC to avoid expansion. To monitor the heap usage, we can useVisualVM shipped with JDK.
  • -XX:SurvivorRatio: Ratio ofeden/survivor space size. For example,-XX:SurvivorRatio=6 sets the ratio between eachsurvivor space andeden space to be 1:6.
  • -XX:+UseLargePages: use large page memory if the system supports it. Please note thatOpenJDK 7 tends to crash if using this JVM parameter.
  • -XX:+UseStringCache:enables caching of commonly allocated strings available in theString pool
  • -XX:+UseCompressedStrings: use abyte[] type forString objects which can be represented in pure ASCII format
  • -XX:+OptimizeStringConcat:it optimizesString concatenation operations where possible

8. Conclusion

In this brief article, we learned about some important JVM parameters, which we can use to tune and improve general application performance. We can also use some of these for debugging purposes.

To explore the reference parameters in more detail, we can take a lookhere.

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

Baeldung Pro comes with both absolutelyNo-Ads as well asfinally withDark Mode, for a clean learning experience:

>> Explore a cleanBaeldung

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

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

Azure Container Apps is a fully managed serverless containerservice that enables you tobuild and deploy modern,cloud-native Java applications and microservices at scale. Itoffers a simplified developer experience while providing theflexibility and portability of containers.

Of course, Azure Container Apps has really solid support for ourecosystem, 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, visitthedocumentation page.

You can also ask questions and leave feedback on the AzureContainer AppsGitHub page.

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

Azure Container Apps is a fully managed serverless containerservice that enables you tobuild and deploy modern,cloud-native Java applications and microservices at scale. Itoffers a simplified developer experience while providing theflexibility and portability of containers.

Of course, Azure Container Apps has really solid support for ourecosystem, 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, visitthedocumentation page.

You can also ask questions and leave feedback on the AzureContainer AppsGitHub page.

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

Modern software architecture is often broken. Slow deliveryleads to missed opportunities, innovation is stalled due toarchitectural complexities, and engineering resources areexceedingly expensive.

Orkes is the leading workflow orchestration platformbuilt 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 canfocus on building mission critical applications without worryingabout infrastructure maintenance to meet goals and, simply put,taking new products live faster and reducing total cost ofownership.

Try a14-Day FreeTrial of Orkes Conductor today.

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

Modern software architecture is often broken. Slow deliveryleads to missed opportunities, innovation is stalled due toarchitectural complexities, and engineering resources areexceedingly expensive.

Orkes is the leading workflow orchestration platformbuilt 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 canfocus on building mission critical applications without worryingabout infrastructure maintenance to meet goals and, simply put,taking new products live faster and reducing total cost ofownership.

Try a14-DayFree Trial of Orkes Conductor today.

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

TheApache HTTP Client is a very robust library, suitablefor both simple and advanced use cases whentesting HTTPendpoints. Check out our guide covering basic request andresponse handling, as well as security, cookies, timeouts, andmore:

>> Downloadthe eBook

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

Handling concurrency in an application can be a tricky processwith manypotential pitfalls. A solid grasp of thefundamentals will go a long way to help minimize these issues.

Get started with understanding multi-threaded applications withourJava 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 astaple of Java development. The basic operations like iterating,filtering, mapping sequences of elements are deceptively simple touse.

But these can also be overused and fall into some commonpitfalls.

Toget a better understanding on how Streams work and howto combine them with other language features, check out our guideto Java Streams:

>> Join Proand 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 wordmatches,often leading to irrelevant results depending onthe user's phrasing.

By comparison, using a vector store allows us to represent thedata as vector embeddings, based on meaningful relationships. Wecan then compare the meaning of the user’s query to the storedcontent, andretrieve more relevant, context-awareresults.

Explore how tobuild an intelligent chatbot using MongoDBAtlas, Langchain4j and Spring Boot:

>>Building an AI Chatbot in Java With Langchain4j and MongoDBAtlas

Course – LS – NPI EA (cat=REST)

announcement - icon

Get started with Spring Boot and with core Spring,through theLearn Spring course:

>> CHECK OUTTHE COURSE

eBook Jackson – NPI EA – 3 (cat = Jackson)
Do JSON right with Jackson - book cover
Do JSON right with Jackson - icon
Do JSON right with Jackson
Download the E-book