<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="http://feeds.feedblitz.com/feedblitz_rss.xslt"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:webfeeds="http://webfeeds.org/rss/1.0"  xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">
<channel>
	<title>Baeldung</title>
	<atom:link href="https://www.baeldung.com/feed" rel="self" type="application/rss+xml" />
	<link>https://www.baeldung.com</link>
	<description>Java, Spring and Web Development tutorials</description>
	<lastBuildDate>Thu, 30 Apr 2026 07:50:21 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
<meta xmlns="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
<item>
<feedburner:origLink>https://www.baeldung.com/java-list-series</feedburner:origLink>
		<title>Java List Series</title>
		<link>https://feeds.feedblitz.com/~/954857483/0/baeldung~Java-List-Series</link>
					<comments>https://feeds.feedblitz.com/~/954857483/0/baeldung~Java-List-Series#respond</comments>
		
		<dc:creator><![CDATA[baeldung]]></dc:creator>
		<pubDate>Thu, 30 Apr 2026 07:50:21 +0000</pubDate>
				<category><![CDATA[Java List]]></category>
		<category><![CDATA[Series]]></category>
		<guid isPermaLink="false">https://www.baeldung.com/?p=203599</guid>
					<description><![CDATA[<img src="https://www.baeldung.com/wp-content/uploads/2024/11/Collections-Featured-Image-01-1024x536.jpg" class="webfeedsFeaturedVisual wp-post-image" alt="" style="max-width:100% !important;height:auto !important;float: left; margin-right: 5px;" fetchpriority="high" /><p>Learn the most common implementations of the List interface and practical List operations.</p>
The post <a rel="NOFOLLOW" href="https://feeds.feedblitz.com/~/954857483/0/baeldung~Java-List-Series">Java List Series</a> first appeared on <a rel="NOFOLLOW" href="https://www.baeldung.com">Baeldung</a>.<div style="clear:both;padding-top:0.2em;"><a title="Like on Facebook" href="https://feeds.feedblitz.com/_/28/954857483/baeldung"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Pin it!" href="https://feeds.feedblitz.com/_/29/954857483/baeldung,https%3a%2f%2fwww.baeldung.com%2fwp-content%2fuploads%2f2024%2f11%2fCollections-Featured-Image-01-1024x536.jpg"><img height="20" src="https://assets.feedblitz.com/i/pinterest20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Post to X.com" href="https://feeds.feedblitz.com/_/24/954857483/baeldung"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by email" href="https://feeds.feedblitz.com/_/19/954857483/baeldung"><img height="20" src="https://assets.feedblitz.com/i/email20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by RSS" href="https://feeds.feedblitz.com/_/20/954857483/baeldung"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a rel="NOFOLLOW" title="View Comments" href="https://www.baeldung.com/java-list-series#respond"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/comments20.png"></a>&#160;<a title="Follow Comments via RSS" href="https://www.baeldung.com/java-list-series/feed"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/commentsrss20.png"></a>&#160;</div>]]>
</description>
										<content:encoded><![CDATA[<img src="https://www.baeldung.com/wp-content/uploads/2024/11/Collections-Featured-Image-01-1024x536.jpg" class="webfeedsFeaturedVisual wp-post-image" alt="" style="float: left; margin-right: 5px;" decoding="async" loading="lazy" srcset="https://www.baeldung.com/wp-content/uploads/2024/11/Collections-Featured-Image-01-1024x536.jpg 1024w, https://www.baeldung.com/wp-content/uploads/2024/11/Collections-Featured-Image-01-300x157.jpg 300w, https://www.baeldung.com/wp-content/uploads/2024/11/Collections-Featured-Image-01-768x402.jpg 768w, https://www.baeldung.com/wp-content/uploads/2024/11/Collections-Featured-Image-01-100x52.jpg 100w, https://www.baeldung.com/wp-content/uploads/2024/11/Collections-Featured-Image-01-600x314.jpg 600w, https://www.baeldung.com/wp-content/uploads/2024/11/Collections-Featured-Image-01.jpg 1200w" sizes="auto, (max-width: 580px) 100vw, 580px" /><p>The <em>List</em> interface is one of Java&#8217;s most essential collection types, offering ordered, index-based access to elements with flexible implementations including <em>ArrayList</em> and <em>LinkedList</em>. Understanding how to create, search, sort, and transform lists is a core skill for any Java developer.</p>
<p>This series covers <strong>practical List operations from the ground up</strong>, organized by task: from picking the right implementation and initializing lists efficiently, through modifying elements, iterating and sorting, finding and filtering, and converting between collection types.</p>
<h2 id="bd-list-types-and-fundamentals" data-id="list-types-and-fundamentals"><img decoding="async" class=" wp-image-196304 alignnone" src="https://baeldung.com/wp-content/uploads/2024/10/main-site-icons-06.png" alt="computer generic" width="52" height="52" /> List Types and Fundamentals</h2>
<div class="bd-anchor" id="list-types-and-fundamentals"></div>
<hr style="margin-top: -50px" />
<ul>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-list-interface">Java List Interface</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-list-vs-arraylist">List vs. ArrayList in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-arraylist-linkedlist">Java ArrayList vs LinkedList</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-set-vs-list">Set vs List in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-arraylist-vs-linkedlist-vs-hashmap">ArrayList vs. LinkedList vs. HashMap in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-copy-on-write-arraylist">Guide to CopyOnWriteArrayList</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-list-of-lists">Working With a List of Lists in Java</a></li>
</ul>
<h2 id="bd-creating-and-initializing-lists" data-id="creating-and-initializing-lists"><img decoding="async" class=" wp-image-196308 alignnone" src="https://baeldung.com/wp-content/uploads/2024/10/main-site-icons-10.png" alt="generic code" width="52" height="52" /> Creating and Initializing Lists</h2>
<div class="bd-anchor" id="creating-and-initializing-lists"></div>
<hr style="margin-top: -50px" />
<ul>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-init-list-one-line">Java List Initialization in One Line</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-arrays-aslist-vs-list-of">Difference Between Arrays.asList() and List.of()</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-collections-emptylist-new-list">Collections.emptyList() vs. New List Instance</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-immutable-list">Immutable ArrayList in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-arraylist-with-zeroes-or-null">Initialize an ArrayList with Zeroes or Null in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-aslist-vs-singletonlist">Arrays.asList() vs Collections.singletonList()</a></li>
</ul>
<h2 id="bd-adding-removing-and-modifying-elements" data-id="adding-removing-and-modifying-elements"><img loading="lazy" decoding="async" class=" wp-image-196318 alignnone" src="https://baeldung.com/wp-content/uploads/2024/10/main-site-icons-20.png" alt="settings generic" width="52" height="52" /> Adding, Removing, and Modifying Elements</h2>
<div class="bd-anchor" id="adding-removing-and-modifying-elements"></div>
<hr style="margin-top: -50px" />
<ul>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-copy-list-to-another">Copy a List to Another List in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-arraylist-deep-copy">How to Deep Copy an ArrayList in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-arraylist-replace-at-index">Replace Element at a Specific Index in a Java ArrayList</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-insert-object-arraylist-specific-position">Inserting an Object in an ArrayList at a Specific Position</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-arraylist-remove-element">Removing an Element From an ArrayList</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-remove-value-from-list">Remove All Occurrences of a Specific Value from a List</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-arraylist-no-duplicates">Avoid Inserting Duplicates in ArrayList in Java</a></li>
</ul>
<h2 id="bd-iterating-and-sorting-lists" data-id="iterating-and-sorting-lists"><img loading="lazy" decoding="async" class=" wp-image-196300 alignnone" src="https://baeldung.com/wp-content/uploads/2024/10/main-site-icons-02.png" alt="algorithm code generic" width="52" height="52" /> Iterating and Sorting Lists</h2>
<div class="bd-anchor" id="iterating-and-sorting-lists"></div>
<hr style="margin-top: -50px" />
<ul>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-iterate-list">Ways to Iterate Over a List in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-list-iterate-backwards">Iterating Backward Through a List</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-reverse-arraylist">Reverse an ArrayList in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-sort-list-alphabetically">Sort a List Alphabetically in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-sort-list-by-date">Sorting Objects in a List by Date</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-max-date-list-streams">Finding Max and Min Date in List Using Streams</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-sorting-one-list-using-another">Sorting One List Based on Another List in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-check-if-list-sorted">Checking If a List Is Sorted in Java</a></li>
</ul>
<h2 id="bd-searching-and-filtering-lists" data-id="searching-and-filtering-lists"><img loading="lazy" decoding="async" class=" wp-image-196301 alignnone" src="https://baeldung.com/wp-content/uploads/2024/10/main-site-icons-03.png" alt="algorithm generic" width="52" height="52" /> Searching and Filtering Lists</h2>
<div class="bd-anchor" id="searching-and-filtering-lists"></div>
<hr style="margin-top: -50px" />
<ul>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/find-list-element-java">How to Find an Element in a List with Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-list-find-duplicates">Finding All Duplicates in a List in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-lists-difference">Finding the Differences Between Two Lists in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-random-list-element">Java &#8211; Get Random Item/Element From a List</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-check-elements-between-lists">Check if a List Contains an Element From Another List in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-lists-intersection">Intersection of Two Lists in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-list-search-case-insensitive">Check if a List Contains a String Element While Ignoring Case</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-unique-values-arraylist">Get Unique Values From an ArrayList in Java</a></li>
</ul>
<h2 id="bd-converting-lists" data-id="converting-lists"><img loading="lazy" decoding="async" class=" wp-image-196307 alignnone" src="https://baeldung.com/wp-content/uploads/2024/10/main-site-icons-09.png" alt="files data" width="52" height="52" /> Converting Lists</h2>
<div class="bd-anchor" id="converting-lists"></div>
<hr style="margin-top: -50px" />
<ul>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-list-split">Partition a List in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/convert-list-to-set-and-set-to-list">Converting Between a List and a Set in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-list-to-map">How to Convert List to Map in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/convert-array-to-list-and-list-to-array">Converting Between an Array and a List in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-string-with-separator-to-list">Convert a Comma Separated String to a List in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-convert-iterator-to-list">Converting Iterator to List</a></li>
</ul>The post <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-list-series">Java List Series</a> first appeared on <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com">Baeldung</a>.<Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/954857483/0/baeldung">
<div style="clear:both;padding-top:0.2em;"><a title="Like on Facebook" href="https://feeds.feedblitz.com/_/28/954857483/baeldung"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Pin it!" href="https://feeds.feedblitz.com/_/29/954857483/baeldung,https%3a%2f%2fwww.baeldung.com%2fwp-content%2fuploads%2f2024%2f11%2fCollections-Featured-Image-01-1024x536.jpg"><img height="20" src="https://assets.feedblitz.com/i/pinterest20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Post to X.com" href="https://feeds.feedblitz.com/_/24/954857483/baeldung"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by email" href="https://feeds.feedblitz.com/_/19/954857483/baeldung"><img height="20" src="https://assets.feedblitz.com/i/email20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by RSS" href="https://feeds.feedblitz.com/_/20/954857483/baeldung"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a rel="NOFOLLOW" title="View Comments" href="https://www.baeldung.com/java-list-series#respond"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/comments20.png"></a>&#160;<a title="Follow Comments via RSS" href="https://www.baeldung.com/java-list-series/feed"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/commentsrss20.png"></a>&#160;</div>]]>
</content:encoded>
					
					<wfw:commentRss>https://feeds.feedblitz.com/~/954857483/0/baeldung~Java-List-Series/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<webfeeds:featuredImage>https://www.baeldung.com/wp-content/uploads/2024/11/Collections-Featured-Image-01-150x150.jpg</webfeeds:featuredImage></item>
<item>
<feedburner:origLink>https://www.baeldung.com/java-httpsession-store-objects</feedburner:origLink>
		<title>Store Java Objects in HttpSession</title>
		<link>https://feeds.feedblitz.com/~/954837605/0/baeldung~Store-Java-Objects-in-HttpSession</link>
					<comments>https://feeds.feedblitz.com/~/954837605/0/baeldung~Store-Java-Objects-in-HttpSession#respond</comments>
		
		<dc:creator><![CDATA[Sourov Jajodia]]></dc:creator>
		<pubDate>Thu, 30 Apr 2026 00:07:54 +0000</pubDate>
				<category><![CDATA[Java Web]]></category>
		<category><![CDATA[Servlet]]></category>
		<guid isPermaLink="false">https://www.baeldung.com/?p=203561</guid>
					<description><![CDATA[<img src="https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-11-1024x536.jpg" class="webfeedsFeaturedVisual wp-post-image" alt="" style="max-width:100% !important;height:auto !important;float: left; margin-right: 5px;" loading="lazy" /><p>Discover the key methods from the HttpSession interface to store, retrieve and remove Java objects from a session.</p>
The post <a rel="NOFOLLOW" href="https://feeds.feedblitz.com/~/954837605/0/baeldung~Store-Java-Objects-in-HttpSession">Store Java Objects in HttpSession</a> first appeared on <a rel="NOFOLLOW" href="https://www.baeldung.com">Baeldung</a>.<div style="clear:both;padding-top:0.2em;"><a title="Like on Facebook" href="https://feeds.feedblitz.com/_/28/954837605/baeldung"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Pin it!" href="https://feeds.feedblitz.com/_/29/954837605/baeldung,https%3a%2f%2fwww.baeldung.com%2fwp-content%2fuploads%2f2024%2f07%2fJava-Featured-11-1024x536.jpg"><img height="20" src="https://assets.feedblitz.com/i/pinterest20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Post to X.com" href="https://feeds.feedblitz.com/_/24/954837605/baeldung"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by email" href="https://feeds.feedblitz.com/_/19/954837605/baeldung"><img height="20" src="https://assets.feedblitz.com/i/email20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by RSS" href="https://feeds.feedblitz.com/_/20/954837605/baeldung"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a rel="NOFOLLOW" title="View Comments" href="https://www.baeldung.com/java-httpsession-store-objects#respond"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/comments20.png"></a>&#160;<a title="Follow Comments via RSS" href="https://www.baeldung.com/java-httpsession-store-objects/feed"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/commentsrss20.png"></a>&#160;</div>]]>
</description>
										<content:encoded><![CDATA[<img src="https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-11-1024x536.jpg" class="webfeedsFeaturedVisual wp-post-image" alt="" style="float: left; margin-right: 5px;" decoding="async" loading="lazy" srcset="https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-11-1024x536.jpg 1024w, https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-11-300x157.jpg 300w, https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-11-768x402.jpg 768w, https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-11-100x52.jpg 100w, https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-11.jpg 1200w" sizes="auto, (max-width: 580px) 100vw, 580px" /><h2 id="bd-introduction" data-id="introduction">1. Introduction</h2>
<div class="bd-anchor" id="introduction"></div>
<p>When developing Java-based web applications, there are many situations where we need to maintain user-related data between HTTP requests. <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-http-request">HTTP</a> is a stateless protocol and does not maintain any information between requests. This means that each HTTP request is independent and has no prior knowledge of the other requests made for the same session.</p>
<p>In this tutorial, we&#8217;ll discuss the basic concepts related to the <em>HttpSession</em> interface in detail. We&#8217;ll also discuss the process of storing, retrieving, and deleting Java objects using the key methods provided by the interface, such as <em>setAttribute(), getAttribute()</em>, and <em>removeAttribute()</em>.</p>
<h2 id="bd-what-is-httpsession" data-id="what-is-httpsession">2. What is <em>HttpSession</em>?</h2>
<div class="bd-anchor" id="what-is-httpsession"></div>
<p><strong>The <em><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-servlet-cookies-session">HttpSession</a></em> interface is a part of the <em>javax.servlet.http</em> package. It&#8217;s used to store a user’s data on the server side between multiple HTTP requests</strong>. HTTP is a stateless protocol. HttpSession fills the gap between HTTP’s statelessness and the need to store a user’s data on the server side by providing a unique session to each user.</p>
<p>The <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/intro-to-servlets">servlet</a> container manages the creation of sessions and tracks them using a unique session ID stored as a cookie named <em>JSESSIONID</em> in the client’s browser. We can access a session from any servlet using the <em>getSession()</em> method of the <em>HttpServletRequest</em> object. Let&#8217;s see an example of obtaining a session:</p>
<pre><code class="language-java">HttpSession session = request.getSession(); </code></pre>
<p>The <em>request.getSession()</em> method will return the existing active session if one has already been created. Otherwise, it&#8217;ll create a brand new one. We can also send the value false as a parameter: <em>request.getSession(false)</em>. This allows us to get the existing session without creating a new one. Once we have the session object, we’re ready to start storing data in it.</p>
<h2 id="bd-storing-a-java-object-in-httpsession" data-id="storing-a-java-object-in-httpsession">3. Storing a Java Object in <em>HttpSession</em></h2>
<div class="bd-anchor" id="storing-a-java-object-in-httpsession"></div>
<p><strong>The <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-classes-objects">Java object</a> is stored within a session by means of a <em>setAttribute()</em> method provided by an <em>HttpSession </em>interface</strong>. The method takes two parameters: a <em>String</em> key and an object to be stored. This makes it easy to associate any Java object with a key for later retrieval.</p>
<p>Let&#8217;s say we have a <i>User</i> class and we want to store a logged-in user&#8217;s data in the session. First, here&#8217;s our simple <i>User</i> class:</p>
<pre><code class="language-java">public class User implements Serializable {
    private String username;
    private String email;
    public User(String username, String email) {
        this.username = username;
        this.email = email;
    }
    public String getUsername() { return username; }
    public String getEmail() { return email; }
}
</code></pre>
<p>Now, here&#8217;s how we store an instance of this object in the session inside a servlet:</p>
<pre><code class="language-java">protected void doPost(HttpServletRequest request, HttpServletResponse response)
  throws ServletException, IOException {
    User user = new User("john_doe", "john@example.com");
    HttpSession session = request.getSession();
    session.setAttribute("loggedInUser", user);
}
</code></pre>
<p>In this example, we first create a new <i>User</i> object with a username and email. Then, we call <i>request.getSession()</i> to obtain the current session. After that, we use <i>session.setAttribute(&#8220;loggedInUser&#8221;, user)</i> to store the object under the key <i>&#8220;loggedInUser&#8221;</i>. From this point on, any servlet or JSP in the same session can access this object using that exact key.</p>
<h2 id="bd-retrieving-a-java-object-from-httpsession" data-id="retrieving-a-java-object-from-httpsession">4. Retrieving a Java Object from <em>HttpSession</em></h2>
<div class="bd-anchor" id="retrieving-a-java-object-from-httpsession"></div>
<p><strong>Once we have stored an object in the session, we need a reliable mechanism to access it in the next request. The <em>getAttribute()</em> function provides exactly that purpose</strong>. It returns the corresponding object given a key used in the <em>setAttribute()</em> function. And so, it enables us to access the user&#8217;s data throughout the entire session.</p>
<p>Building on our previous example, here&#8217;s how we retrieve the stored <i>User</i> object in another servlet:</p>
<pre><code class="language-java">protected void doGet(HttpServletRequest request, HttpServletResponse response)
  throws ServletException, IOException {
    HttpSession session = request.getSession(false);
    private static final Logger logger = LoggerFactory.getLogger(StoreSessionServlet.class);
    if (session != null) {
        User user = (User) session.getAttribute("loggedInUser");
        if (user != null) {
            logger.info("Welcome back, " + user.getUsername());
        } else {
            logger.info("No user found in session.");
        }
    } else {
        logger.info("No active session found.");
    }
}
</code></pre>
<p>First, we begin with a call to <em>request.getSession(false)</em> to obtain the current session without accidentally opening a new session. Then, we retrieve the stored object via <em>session.getAttribute(&#8220;loggedInUser&#8221;)</em>, casting it to <em>User</em>. The key point is to always check that it is not null. For example, a session has timed out, or maybe we haven’t yet set the attribute. So, a simple null check is a common pattern to keep our code safe from potential <em>NullPointerException</em> issues.</p>
<h2 id="bd-removing-an-object-from-httpsession" data-id="removing-an-object-from-httpsession">5. Removing an Object from <em>HttpSession</em></h2>
<div class="bd-anchor" id="removing-an-object-from-httpsession"></div>
<p><strong>At some point, we&#8217;ll have to clean up the session data that&#8217;s no longer required</strong>. For example, we clear the user’s details when the user logs out or clear a specific attribute. The <em>HttpSession</em> interface provides two ways of doing it: <em>removeAttribute()</em>, which removes a specific object, and <em>invalidate()</em>, which clears the session.</p>
<p>Here&#8217;s how we use both in practice:</p>
<pre><code class="language-java">protected void doPost(HttpServletRequest request, HttpServletResponse response)
  throws ServletException, IOException {
    HttpSession session = request.getSession(false);
    if (session != null) {
        session.removeAttribute("loggedInUser");
        session.invalidate();
    }
}
</code></pre>
<p>In this example, we begin by retrieving the existing session through <em>request.getSession(false)</em>. Then, we remove the existing <em>User</em> object we previously stored by calling <em>session.removeAttribute(&#8220;loggedInUser&#8221;)</em>, leaving all other session data intact. <em>session.invalidate()</em> removes the entire session, clearing all the data contained within the session from memory. Moreover, it is important to include a null check to avoid errors when there is no active session.</p>
<h2 id="bd-conclusion" data-id="conclusion">6. Conclusion</h2>
<div class="bd-anchor" id="conclusion"></div>
<p>In this article, we’ve discussed how to manage Java objects within an <em>HttpSession</em> using three basic operations: <em>setAttribute</em> to put objects into the session, <em>getAttribute</em> to retrieve objects from the session, and <em>removeAttribute</em> to clean up specific objects from the session. As you can see, we have good control over objects stored within a session and can use this to build stateful, user-aware web applications using the stateless HTTP protocol.</p>
<p>Beyond the basics, we also saw why careful session handling matters. We perform <i>null</i> checks when retrieving attributes and call <i>invalidate()</i> on logout to prevent stale data from lingering on the server. With these fundamentals in place, we&#8217;re able to tackle real-world session management challenges and build Java web applications that are both robust and secure.</p>
<p>As always, the full code is available over on <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://github.com/Sourov72/tutorials/tree/master/web-modules/jakarta-servlets">Github</a>.</p>The post <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-httpsession-store-objects">Store Java Objects in HttpSession</a> first appeared on <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com">Baeldung</a>.<Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/954837605/0/baeldung">
<div style="clear:both;padding-top:0.2em;"><a title="Like on Facebook" href="https://feeds.feedblitz.com/_/28/954837605/baeldung"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Pin it!" href="https://feeds.feedblitz.com/_/29/954837605/baeldung,https%3a%2f%2fwww.baeldung.com%2fwp-content%2fuploads%2f2024%2f07%2fJava-Featured-11-1024x536.jpg"><img height="20" src="https://assets.feedblitz.com/i/pinterest20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Post to X.com" href="https://feeds.feedblitz.com/_/24/954837605/baeldung"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by email" href="https://feeds.feedblitz.com/_/19/954837605/baeldung"><img height="20" src="https://assets.feedblitz.com/i/email20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by RSS" href="https://feeds.feedblitz.com/_/20/954837605/baeldung"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a rel="NOFOLLOW" title="View Comments" href="https://www.baeldung.com/java-httpsession-store-objects#respond"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/comments20.png"></a>&#160;<a title="Follow Comments via RSS" href="https://www.baeldung.com/java-httpsession-store-objects/feed"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/commentsrss20.png"></a>&#160;</div>]]>
</content:encoded>
					
					<wfw:commentRss>https://feeds.feedblitz.com/~/954837605/0/baeldung~Store-Java-Objects-in-HttpSession/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<webfeeds:featuredImage>https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-11-150x150.jpg</webfeeds:featuredImage></item>
<item>
<feedburner:origLink>https://www.baeldung.com/java-algorithms-series</feedburner:origLink>
		<title>Algorithms in Java Series</title>
		<link>https://feeds.feedblitz.com/~/954821783/0/baeldung~Algorithms-in-Java-Series</link>
					<comments>https://feeds.feedblitz.com/~/954821783/0/baeldung~Algorithms-in-Java-Series#respond</comments>
		
		<dc:creator><![CDATA[baeldung]]></dc:creator>
		<pubDate>Wed, 29 Apr 2026 17:40:01 +0000</pubDate>
				<category><![CDATA[Algorithms]]></category>
		<category><![CDATA[Series]]></category>
		<guid isPermaLink="false">https://www.baeldung.com/?p=203581</guid>
					<description><![CDATA[<img src="https://www.baeldung.com/wp-content/uploads/2024/11/Algorithms-Featured-Image-02-1024x536.jpg" class="webfeedsFeaturedVisual wp-post-image" alt="" style="max-width:100% !important;height:auto !important;float: left; margin-right: 5px;" loading="lazy" /><p>A guide to fundamental algorithms implemented in Java.</p>
The post <a rel="NOFOLLOW" href="https://feeds.feedblitz.com/~/954821783/0/baeldung~Algorithms-in-Java-Series">Algorithms in Java Series</a> first appeared on <a rel="NOFOLLOW" href="https://www.baeldung.com">Baeldung</a>.<div style="clear:both;padding-top:0.2em;"><a title="Like on Facebook" href="https://feeds.feedblitz.com/_/28/954821783/baeldung"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Pin it!" href="https://feeds.feedblitz.com/_/29/954821783/baeldung,https%3a%2f%2fwww.baeldung.com%2fwp-content%2fuploads%2f2024%2f11%2fAlgorithms-Featured-Image-02-1024x536.jpg"><img height="20" src="https://assets.feedblitz.com/i/pinterest20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Post to X.com" href="https://feeds.feedblitz.com/_/24/954821783/baeldung"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by email" href="https://feeds.feedblitz.com/_/19/954821783/baeldung"><img height="20" src="https://assets.feedblitz.com/i/email20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by RSS" href="https://feeds.feedblitz.com/_/20/954821783/baeldung"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a rel="NOFOLLOW" title="View Comments" href="https://www.baeldung.com/java-algorithms-series#respond"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/comments20.png"></a>&#160;<a title="Follow Comments via RSS" href="https://www.baeldung.com/java-algorithms-series/feed"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/commentsrss20.png"></a>&#160;</div>]]>
</description>
										<content:encoded><![CDATA[<img src="https://www.baeldung.com/wp-content/uploads/2024/11/Algorithms-Featured-Image-02-1024x536.jpg" class="webfeedsFeaturedVisual wp-post-image" alt="" style="float: left; margin-right: 5px;" decoding="async" loading="lazy" srcset="https://www.baeldung.com/wp-content/uploads/2024/11/Algorithms-Featured-Image-02-1024x536.jpg 1024w, https://www.baeldung.com/wp-content/uploads/2024/11/Algorithms-Featured-Image-02-300x157.jpg 300w, https://www.baeldung.com/wp-content/uploads/2024/11/Algorithms-Featured-Image-02-768x402.jpg 768w, https://www.baeldung.com/wp-content/uploads/2024/11/Algorithms-Featured-Image-02-100x52.jpg 100w, https://www.baeldung.com/wp-content/uploads/2024/11/Algorithms-Featured-Image-02-600x314.jpg 600w, https://www.baeldung.com/wp-content/uploads/2024/11/Algorithms-Featured-Image-02.jpg 1200w" sizes="auto, (max-width: 580px) 100vw, 580px" /><p>Algorithms are at the heart of software development, providing foundational solutions to recurring computational problems. From classic sorting routines and graph traversal to advanced optimization and concurrency patterns, a strong grasp of algorithms enables Java developers to write code that is both efficient and correct.</p>
<p>This curated series covers <strong>the most important algorithms implemented in Java</strong>, organized by topic to guide you from core sorting and searching techniques through graph theory, mathematical computation, string processing, and systems design.</p>
<h2 id="bd-sorting-and-searching" data-id="sorting-and-searching"><img loading="lazy" decoding="async" class=" wp-image-196300 alignnone" src="https://baeldung.com/wp-content/uploads/2024/10/main-site-icons-02.png" alt="algorithm code generic" width="52" height="52" /> Sorting and Searching</h2>
<div class="bd-anchor" id="sorting-and-searching"></div>
<hr style="margin-top: -50px" />
<ul>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-binary-search">Binary Search Algorithm in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-bubble-sort">Bubble Sort in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-selection-sort">Selection Sort in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-merge-sort">Merge Sort in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-quicksort">Quicksort Algorithm Implementation in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-heap-sort">Heap Sort in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-radix-sort">Radix Sort in Java</a></li>
</ul>
<h2 id="bd-graph-and-tree-algorithms" data-id="graph-and-tree-algorithms"><img loading="lazy" decoding="async" class=" wp-image-196311 alignnone" src="https://baeldung.com/wp-content/uploads/2024/10/main-site-icons-13.png" alt="network system connection" width="52" height="52" /> Graph and Tree Algorithms</h2>
<div class="bd-anchor" id="graph-and-tree-algorithms"></div>
<hr style="margin-top: -50px" />
<ul>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-binary-tree">Implementing a Binary Tree in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-graphs">Graphs in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-depth-first-search">Depth First Search in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-breadth-first-search">Breadth-First Search Algorithm in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-avl-trees">Guide to AVL Trees in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-dijkstra">Dijkstra Shortest Path Algorithm in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-a-star-pathfinding">Implementing A* Pathfinding in Java</a></li>
</ul>
<h2 id="bd-array-and-string-algorithms" data-id="array-and-string-algorithms"><img loading="lazy" decoding="async" class=" wp-image-196308 alignnone" src="https://baeldung.com/wp-content/uploads/2024/10/main-site-icons-10.png" alt="generic code" width="52" height="52" /> Array and String Algorithms</h2>
<div class="bd-anchor" id="array-and-string-algorithms"></div>
<hr style="margin-top: -50px" />
<ul>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-two-pointer-technique">Java Two Pointer Technique</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-maximum-subarray">Maximum Subarray Problem in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-array-permutations">Permutations of an Array in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-reverse-linked-list">Reversing a Linked List in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-balanced-brackets-algorithm">Balanced Brackets Algorithm in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-caesar-cipher">The Caesar Cipher in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-levenshtein-distance">How to Calculate Levenshtein Distance in Java?</a></li>
</ul>
<h2 id="bd-mathematical-algorithms" data-id="mathematical-algorithms"><img loading="lazy" decoding="async" class=" wp-image-196301 alignnone" src="https://baeldung.com/wp-content/uploads/2024/10/main-site-icons-03.png" alt="algorithm generic" width="52" height="52" /> Mathematical Algorithms</h2>
<div class="bd-anchor" id="mathematical-algorithms"></div>
<hr style="margin-top: -50px" />
<ul>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-calculate-factorial">Calculate Factorial in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-fibonacci">Fibonacci Series in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-greatest-common-divisor">Finding Greatest Common Divisor in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-least-common-multiple">Finding the Least Common Multiple in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-matrix-multiplication">Matrix Multiplication in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-pascal-triangle">Java Program to Print Pascal&#8217;s Triangle</a></li>
</ul>
<h2 id="bd-optimization-and-ai-algorithms" data-id="optimization-and-ai-algorithms"><img loading="lazy" decoding="async" class=" wp-image-196312 alignnone" src="https://baeldung.com/wp-content/uploads/2024/10/main-site-icons-14.png" alt="user thinking generic" width="52" height="52" /> Optimization and AI Algorithms</h2>
<div class="bd-anchor" id="optimization-and-ai-algorithms"></div>
<hr style="margin-top: -50px" />
<ul>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-greedy-algorithms">Introduction to Greedy Algorithms with Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-knapsack">Knapsack Problem Implementation in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-minimax-algorithm">Introduction to Minimax Algorithm with a Java Implementation</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-sudoku">Create a Sudoku Solver in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-hill-climbing-algorithm">Example of Hill Climbing Algorithm in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-solve-maze">A Maze Solver in Java</a></li>
</ul>
<h2 id="bd-concurrency-and-systems-algorithms" data-id="concurrency-and-systems-algorithms"><img loading="lazy" decoding="async" class=" wp-image-196316 alignnone" src="https://baeldung.com/wp-content/uploads/2024/10/main-site-icons-18.png" alt="launch program running" width="52" height="52" /> Concurrency and Systems Algorithms</h2>
<div class="bd-anchor" id="concurrency-and-systems-algorithms"></div>
<hr style="margin-top: -50px" />
<ul>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-lru-cache">How to Implement LRU Cache in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-ring-buffer">Implementing a Ring Buffer in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/lock-free-programming">Introduction to Lock-Free Data Structures with Java Examples</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/resilience4j-backoff-jitter">Better Retries with Exponential Backoff and Jitter</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-producer-consumer-problem">Producer-Consumer Problem With Example in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-dining-philoshophers">The Dining Philosophers Problem in Java</a></li>
</ul>The post <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-algorithms-series">Algorithms in Java Series</a> first appeared on <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com">Baeldung</a>.<Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/954821783/0/baeldung">
<div style="clear:both;padding-top:0.2em;"><a title="Like on Facebook" href="https://feeds.feedblitz.com/_/28/954821783/baeldung"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Pin it!" href="https://feeds.feedblitz.com/_/29/954821783/baeldung,https%3a%2f%2fwww.baeldung.com%2fwp-content%2fuploads%2f2024%2f11%2fAlgorithms-Featured-Image-02-1024x536.jpg"><img height="20" src="https://assets.feedblitz.com/i/pinterest20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Post to X.com" href="https://feeds.feedblitz.com/_/24/954821783/baeldung"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by email" href="https://feeds.feedblitz.com/_/19/954821783/baeldung"><img height="20" src="https://assets.feedblitz.com/i/email20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by RSS" href="https://feeds.feedblitz.com/_/20/954821783/baeldung"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a rel="NOFOLLOW" title="View Comments" href="https://www.baeldung.com/java-algorithms-series#respond"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/comments20.png"></a>&#160;<a title="Follow Comments via RSS" href="https://www.baeldung.com/java-algorithms-series/feed"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/commentsrss20.png"></a>&#160;</div>]]>
</content:encoded>
					
					<wfw:commentRss>https://feeds.feedblitz.com/~/954821783/0/baeldung~Algorithms-in-Java-Series/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<webfeeds:featuredImage>https://www.baeldung.com/wp-content/uploads/2024/11/Algorithms-Featured-Image-02-150x150.jpg</webfeeds:featuredImage></item>
<item>
<feedburner:origLink>https://www.baeldung.com/spring-ai-series</feedburner:origLink>
		<title>Spring AI Series</title>
		<link>https://feeds.feedblitz.com/~/954792065/0/baeldung~Spring-AI-Series</link>
					<comments>https://feeds.feedblitz.com/~/954792065/0/baeldung~Spring-AI-Series#respond</comments>
		
		<dc:creator><![CDATA[baeldung]]></dc:creator>
		<pubDate>Wed, 29 Apr 2026 08:43:50 +0000</pubDate>
				<category><![CDATA[Series]]></category>
		<category><![CDATA[Spring AI]]></category>
		<guid isPermaLink="false">https://www.baeldung.com/?p=203577</guid>
					<description><![CDATA[<img src="https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-11-1024x536.jpg" class="webfeedsFeaturedVisual wp-post-image" alt="" style="max-width:100% !important;height:auto !important;float: left; margin-right: 5px;" loading="lazy" /><p>A series of tutorials on building AI applications with Spring AI.</p>
The post <a rel="NOFOLLOW" href="https://feeds.feedblitz.com/~/954792065/0/baeldung~Spring-AI-Series">Spring AI Series</a> first appeared on <a rel="NOFOLLOW" href="https://www.baeldung.com">Baeldung</a>.<div style="clear:both;padding-top:0.2em;"><a title="Like on Facebook" href="https://feeds.feedblitz.com/_/28/954792065/baeldung"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Pin it!" href="https://feeds.feedblitz.com/_/29/954792065/baeldung,https%3a%2f%2fwww.baeldung.com%2fwp-content%2fuploads%2f2024%2f07%2fJava-Featured-11-1024x536.jpg"><img height="20" src="https://assets.feedblitz.com/i/pinterest20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Post to X.com" href="https://feeds.feedblitz.com/_/24/954792065/baeldung"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by email" href="https://feeds.feedblitz.com/_/19/954792065/baeldung"><img height="20" src="https://assets.feedblitz.com/i/email20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by RSS" href="https://feeds.feedblitz.com/_/20/954792065/baeldung"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a rel="NOFOLLOW" title="View Comments" href="https://www.baeldung.com/spring-ai-series#respond"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/comments20.png"></a>&#160;<a title="Follow Comments via RSS" href="https://www.baeldung.com/spring-ai-series/feed"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/commentsrss20.png"></a>&#160;</div>]]>
</description>
										<content:encoded><![CDATA[<img src="https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-11-1024x536.jpg" class="webfeedsFeaturedVisual wp-post-image" alt="" style="float: left; margin-right: 5px;" decoding="async" loading="lazy" srcset="https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-11-1024x536.jpg 1024w, https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-11-300x157.jpg 300w, https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-11-768x402.jpg 768w, https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-11-100x52.jpg 100w, https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-11.jpg 1200w" sizes="auto, (max-width: 580px) 100vw, 580px" /><p>Spring AI is a comprehensive framework for building AI-powered applications on the Spring platform, providing abstractions over language model providers. It enables Java developers to integrate conversational AI, retrieval-augmented generation, and agentic workflows into their applications using familiar Spring patterns.</p>
<p>This curated series provides <strong>a practical guide to building AI applications with Spring AI</strong>, from core chat and memory concepts to advanced patterns like RAG pipelines, custom advisors, AI agents, and Model Context Protocol (MCP) integration.</p>
<h2 id="bd-getting-started-with-spring-ai" data-id="getting-started-with-spring-ai"><img loading="lazy" decoding="async" class=" wp-image-196308 alignnone" src="https://baeldung.com/wp-content/uploads/2024/10/main-site-icons-10.png" alt="generic code" width="52" height="52" /> Getting Started with Spring AI</h2>
<div class="bd-anchor" id="getting-started-with-spring-ai"></div>
<hr style="margin-top: -50px" />
<ul>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai">Introduction to Spring AI</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-chatclient">ChatClient Fluent API in Spring AI</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-chat-memory">Chat Memory in Spring AI</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-chatclient-stream-response">Streaming Response in Spring AI ChatClient</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-configure-multiple-llms">Configuring Multiple LLMs in Spring AI</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-artificial-intelligence-structure-output">A Guide to Structured Output in Spring AI</a></li>
</ul>
<h2 id="bd-ai-models-and-providers" data-id="ai-models-and-providers"><img loading="lazy" decoding="async" class=" wp-image-196302 alignnone" src="https://baeldung.com/wp-content/uploads/2024/10/main-site-icons-04.png" alt="network generic" width="52" height="52" /> AI Models and Providers</h2>
<div class="bd-anchor" id="ai-models-and-providers"></div>
<hr style="margin-top: -50px" />
<ul>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-anthropics-claude-models">Using Anthropic&#8217;s Claude Models With Spring AI</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-google-cloud">Google Cloud and Spring AI</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-deepseek-cot">Building an AI Chatbot Using DeepSeek Models With Spring AI</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-ollama-hugging-face-models">Using Hugging Face Models With Spring AI and Ollama</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-ollama-chatgpt-like-chatbot">Create a ChatGPT Like Chatbot With Ollama and Spring AI</a></li>
</ul>
<h2 id="bd-rag-and-vector-stores" data-id="rag-and-vector-stores"><img loading="lazy" decoding="async" class=" wp-image-196306 alignnone" src="https://baeldung.com/wp-content/uploads/2024/10/main-site-icons-08.png" alt="database data" width="52" height="52" /> RAG and Vector Stores</h2>
<div class="bd-anchor" id="rag-and-vector-stores"></div>
<hr style="margin-top: -50px" />
<ul>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-embeddings-model-api">A Guide to Embeddings Model API in Spring AI</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-redis-rag-app">Create a RAG (Retrieval Augmented Generation) Application with Redis and Spring AI</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-pgvector-semantic-search">Implementing Semantic Search Using Spring AI and PGVector</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-chromadb-vector-store">Spring AI With ChromaDB Vector Store</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-mongodb-rag">Building a RAG App Using MongoDB and Spring AI</a></li>
</ul>
<h2 id="bd-advisors-and-ai-agents" data-id="advisors-and-ai-agents"><img loading="lazy" decoding="async" class=" wp-image-196312 alignnone" src="https://baeldung.com/wp-content/uploads/2024/10/main-site-icons-14.png" alt="user thinking generic" width="52" height="52" /> Advisors and AI Agents</h2>
<div class="bd-anchor" id="advisors-and-ai-agents"></div>
<hr style="margin-top: -50px" />
<ul>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-advisors">A Guide to Spring AI Advisors</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-recursive-advisors">A Guide to Spring AI Recursive Advisors</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-building-effective-agents">Building Effective Agents with Spring AI</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-explainable-agents-capture-llm-tool-call-reasoning">Explainable AI Agents: Capture LLM Tool Call Reasoning with Spring AI</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-assistant">Implementing an AI Assistant with Spring AI</a></li>
</ul>
<h2 id="bd-model-context-protocol-mcp" data-id="model-context-protocol-mcp"><img loading="lazy" decoding="async" class=" wp-image-196311 alignnone" src="https://baeldung.com/wp-content/uploads/2024/10/main-site-icons-13.png" alt="network system connection" width="52" height="52" /> Model Context Protocol (MCP)</h2>
<div class="bd-anchor" id="model-context-protocol-mcp"></div>
<hr style="margin-top: -50px" />
<ul>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-model-context-protocol-mcp">Exploring Model Context Protocol (MCP) With Spring AI</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-mcp-annotations">Overview of MCP Annotations in Spring AI</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-mcp-elicitations">MCP Elicitations With Spring AI</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-oath2-mcp-authorization">MCP Authorization With Spring AI and OAuth2</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-mcp-servers-oauth2">Securing Spring AI MCP Servers With OAuth2</a></li>
</ul>
<h2 id="bd-multimodal-and-advanced-capabilities" data-id="multimodal-and-advanced-capabilities"><img loading="lazy" decoding="async" class=" wp-image-196316 alignnone" src="https://baeldung.com/wp-content/uploads/2024/10/main-site-icons-18.png" alt="launch program running" width="52" height="52" /> Multimodal and Advanced Capabilities</h2>
<div class="bd-anchor" id="multimodal-and-advanced-capabilities"></div>
<hr style="margin-top: -50px" />
<ul>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-extract-data-from-images">Extracting Structured Data From Images Using Spring AI</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-testing-ai-evaluators">Testing LLM Responses Using Spring AI Evaluators</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-text-to-sql">Text-to-SQL Implementation Using Spring AI</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-transcribing-audio-files">Transcribing Audio Files With OpenAI in Spring AI</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-mistral-api-function-calling">Function Calling in Java and Spring AI Using the Mistral AI API</a></li>
</ul>The post <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-series">Spring AI Series</a> first appeared on <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com">Baeldung</a>.<Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/954792065/0/baeldung">
<div style="clear:both;padding-top:0.2em;"><a title="Like on Facebook" href="https://feeds.feedblitz.com/_/28/954792065/baeldung"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Pin it!" href="https://feeds.feedblitz.com/_/29/954792065/baeldung,https%3a%2f%2fwww.baeldung.com%2fwp-content%2fuploads%2f2024%2f07%2fJava-Featured-11-1024x536.jpg"><img height="20" src="https://assets.feedblitz.com/i/pinterest20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Post to X.com" href="https://feeds.feedblitz.com/_/24/954792065/baeldung"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by email" href="https://feeds.feedblitz.com/_/19/954792065/baeldung"><img height="20" src="https://assets.feedblitz.com/i/email20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by RSS" href="https://feeds.feedblitz.com/_/20/954792065/baeldung"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a rel="NOFOLLOW" title="View Comments" href="https://www.baeldung.com/spring-ai-series#respond"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/comments20.png"></a>&#160;<a title="Follow Comments via RSS" href="https://www.baeldung.com/spring-ai-series/feed"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/commentsrss20.png"></a>&#160;</div>]]>
</content:encoded>
					
					<wfw:commentRss>https://feeds.feedblitz.com/~/954792065/0/baeldung~Spring-AI-Series/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<webfeeds:featuredImage>https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-11-150x150.jpg</webfeeds:featuredImage></item>
<item>
<feedburner:origLink>https://www.baeldung.com/java-ai-series</feedburner:origLink>
		<title>AI in Java Series</title>
		<link>https://feeds.feedblitz.com/~/954788495/0/baeldung~AI-in-Java-Series</link>
					<comments>https://feeds.feedblitz.com/~/954788495/0/baeldung~AI-in-Java-Series#respond</comments>
		
		<dc:creator><![CDATA[baeldung]]></dc:creator>
		<pubDate>Wed, 29 Apr 2026 06:59:57 +0000</pubDate>
				<category><![CDATA[Artificial Intelligence]]></category>
		<category><![CDATA[Series]]></category>
		<guid isPermaLink="false">https://www.baeldung.com/?p=203573</guid>
					<description><![CDATA[<img src="https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-12-1024x536.jpg" class="webfeedsFeaturedVisual wp-post-image" alt="" style="max-width:100% !important;height:auto !important;float: left; margin-right: 5px;" loading="lazy" /><p>A curated series of guides to building AI-powered applications in Java.</p>
The post <a rel="NOFOLLOW" href="https://feeds.feedblitz.com/~/954788495/0/baeldung~AI-in-Java-Series">AI in Java Series</a> first appeared on <a rel="NOFOLLOW" href="https://www.baeldung.com">Baeldung</a>.<div style="clear:both;padding-top:0.2em;"><a title="Like on Facebook" href="https://feeds.feedblitz.com/_/28/954788495/baeldung"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Pin it!" href="https://feeds.feedblitz.com/_/29/954788495/baeldung,https%3a%2f%2fwww.baeldung.com%2fwp-content%2fuploads%2f2024%2f07%2fJava-Featured-12-1024x536.jpg"><img height="20" src="https://assets.feedblitz.com/i/pinterest20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Post to X.com" href="https://feeds.feedblitz.com/_/24/954788495/baeldung"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by email" href="https://feeds.feedblitz.com/_/19/954788495/baeldung"><img height="20" src="https://assets.feedblitz.com/i/email20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by RSS" href="https://feeds.feedblitz.com/_/20/954788495/baeldung"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a rel="NOFOLLOW" title="View Comments" href="https://www.baeldung.com/java-ai-series#respond"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/comments20.png"></a>&#160;<a title="Follow Comments via RSS" href="https://www.baeldung.com/java-ai-series/feed"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/commentsrss20.png"></a>&#160;</div>]]>
</description>
										<content:encoded><![CDATA[<img src="https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-12-1024x536.jpg" class="webfeedsFeaturedVisual wp-post-image" alt="" style="float: left; margin-right: 5px;" decoding="async" loading="lazy" srcset="https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-12-1024x536.jpg 1024w, https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-12-300x157.jpg 300w, https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-12-768x402.jpg 768w, https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-12-100x52.jpg 100w, https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-12.jpg 1200w" sizes="auto, (max-width: 580px) 100vw, 580px" /><p>Artificial intelligence has become a core concern for Java developers, with a growing ecosystem of frameworks and tools for building everything from simple chatbots to sophisticated agentic systems. Java offers strong support for modern AI development through frameworks like <em>Spring AI</em> and <em>LangChain4j</em>, as well as direct integrations with the major LLM providers.</p>
<p>This curated series provides <strong>a practical guide to building AI-powered applications in Java</strong>, covering foundational concepts, Spring AI&#8217;s core features, retrieval-augmented generation, the Model Context Protocol, AI agents, and deep learning libraries.</p>
<h2 id="bd-getting-started-with-ai-in-java" data-id="getting-started-with-ai-in-java"><img loading="lazy" decoding="async" class=" wp-image-196304 alignnone" src="https://www.baeldung.com/wp-content/uploads/2024/10/main-site-icons-06.png" alt="computer generic" width="52" height="52" /> Getting Started with AI in Java</h2>
<div class="bd-anchor" id="getting-started-with-ai-in-java"></div>
<hr style="margin-top: -50px" />
<ul>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai">Introduction to Spring AI</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-langchain-basics">Introduction to LangChain</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-openai-api-client">The OpenAI API Java Client</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-boot-chatgpt-api-openai">Using OpenAI ChatGPT APIs in Spring Boot</a></li>
</ul>
<h2 id="bd-building-with-spring-ai" data-id="building-with-spring-ai"><img loading="lazy" decoding="async" class=" wp-image-196300 alignnone" src="https://www.baeldung.com/wp-content/uploads/2024/10/main-site-icons-02.png" alt="algorithm code generic" width="52" height="52" /> Building with Spring AI</h2>
<div class="bd-anchor" id="building-with-spring-ai"></div>
<hr style="margin-top: -50px" />
<ul>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-chatclient">ChatClient Fluent API in Spring AI</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-chat-memory">Chat Memory in Spring AI</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-artificial-intelligence-structure-output">A Guide to Structured Output in Spring AI</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-advisors">A Guide to Spring AI Advisors</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-anthropics-claude-models">Using Anthropic&#8217;s Claude Models With Spring AI</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-deepseek-cot">Building an AI Chatbot Using DeepSeek Models With Spring AI</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-ollama-chatgpt-like-chatbot">Create a ChatGPT Like Chatbot With Ollama and Spring AI</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-testing-ai-evaluators">Testing LLM Responses Using Spring AI Evaluators</a></li>
</ul>
<h2 id="bd-rag-and-vector-search" data-id="rag-and-vector-search"><img loading="lazy" decoding="async" class=" wp-image-196306 alignnone" src="https://www.baeldung.com/wp-content/uploads/2024/10/main-site-icons-08.png" alt="database data" width="52" height="52" /> RAG and Vector Search</h2>
<div class="bd-anchor" id="rag-and-vector-search"></div>
<hr style="margin-top: -50px" />
<ul>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-embeddings-model-api">A Guide to Embeddings Model API in Spring AI</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-redis-rag-app">Create a RAG (Retrieval Augmented Generation) Application with Redis and Spring AI</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-langchain-mongodb">Building an AI Chatbot in Java With Langchain4j and MongoDB Atlas</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-pgvector-semantic-search">Implementing Semantic Search Using Spring AI and PGVector</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-chromadb-vector-store">Spring AI With ChromaDB Vector Store</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-mongodb-rag">Building a RAG App Using MongoDB and Spring AI</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-semantic-caching">Implementing Semantic Caching Using Spring AI</a></li>
</ul>
<h2 id="bd-model-context-protocol-mcp" data-id="model-context-protocol-mcp"><img loading="lazy" decoding="async" class=" wp-image-196311 alignnone" src="https://www.baeldung.com/wp-content/uploads/2024/10/main-site-icons-13.png" alt="network system connection" width="52" height="52" /> Model Context Protocol (MCP)</h2>
<div class="bd-anchor" id="model-context-protocol-mcp"></div>
<hr style="margin-top: -50px" />
<ul>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-sdk-model-context-protocol">Introduction to the Model Context Protocol (MCP) Java SDK</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-model-context-protocol-mcp">Exploring Model Context Protocol (MCP) With Spring AI</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-oath2-mcp-authorization">MCP Authorization With Spring AI and OAuth2</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-mcp-servers-oauth2">Securing Spring AI MCP Servers With OAuth2</a></li>
</ul>
<h2 id="bd-ai-agents" data-id="ai-agents"><img loading="lazy" decoding="async" class=" wp-image-196316 alignnone" src="https://www.baeldung.com/wp-content/uploads/2024/10/main-site-icons-18.png" alt="launch program running" width="52" height="52" /> AI Agents</h2>
<div class="bd-anchor" id="ai-agents"></div>
<hr style="margin-top: -50px" />
<ul>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-embabel-agent-framework">Creating an AI Agent in Java Using Embabel Agent Framework</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-google-agent-development-kit">Building AI Agents Using Google Agent Development Kit (ADK)</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-text-to-sql">Text-to-SQL Implementation Using Spring AI</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-ai-assistant">Implementing an AI Assistant with Spring AI</a></li>
</ul>
<h2 id="bd-deep-learning-and-ml-libraries" data-id="deep-learning-and-ml-libraries"><img loading="lazy" decoding="async" class=" wp-image-196301 alignnone" src="https://www.baeldung.com/wp-content/uploads/2024/10/main-site-icons-03.png" alt="algorithm generic" width="52" height="52" /> Deep Learning and ML Libraries</h2>
<div class="bd-anchor" id="deep-learning-and-ml-libraries"></div>
<hr style="margin-top: -50px" />
<ul>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-ai">Overview of AI Libraries in Java</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-djl-guide">A Guide to Deep Java Library</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/deeplearning4j">A Guide to Deeplearning4j</a></li>
<li style="margin-bottom: 5px"><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-jlama-llm">Introduction to Jlama</a></li>
</ul>The post <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-ai-series">AI in Java Series</a> first appeared on <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com">Baeldung</a>.<Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/954788495/0/baeldung">
<div style="clear:both;padding-top:0.2em;"><a title="Like on Facebook" href="https://feeds.feedblitz.com/_/28/954788495/baeldung"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Pin it!" href="https://feeds.feedblitz.com/_/29/954788495/baeldung,https%3a%2f%2fwww.baeldung.com%2fwp-content%2fuploads%2f2024%2f07%2fJava-Featured-12-1024x536.jpg"><img height="20" src="https://assets.feedblitz.com/i/pinterest20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Post to X.com" href="https://feeds.feedblitz.com/_/24/954788495/baeldung"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by email" href="https://feeds.feedblitz.com/_/19/954788495/baeldung"><img height="20" src="https://assets.feedblitz.com/i/email20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by RSS" href="https://feeds.feedblitz.com/_/20/954788495/baeldung"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a rel="NOFOLLOW" title="View Comments" href="https://www.baeldung.com/java-ai-series#respond"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/comments20.png"></a>&#160;<a title="Follow Comments via RSS" href="https://www.baeldung.com/java-ai-series/feed"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/commentsrss20.png"></a>&#160;</div>]]>
</content:encoded>
					
					<wfw:commentRss>https://feeds.feedblitz.com/~/954788495/0/baeldung~AI-in-Java-Series/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<webfeeds:featuredImage>https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-12-150x150.jpg</webfeeds:featuredImage></item>
<item>
<feedburner:origLink>https://www.baeldung.com/hibernate-named-entity-graph</feedburner:origLink>
		<title>A Guide to @NamedEntityGraph in Hibernate</title>
		<link>https://feeds.feedblitz.com/~/954520139/0/baeldung~A-Guide-to-NamedEntityGraph-in-Hibernate</link>
					<comments>https://feeds.feedblitz.com/~/954520139/0/baeldung~A-Guide-to-NamedEntityGraph-in-Hibernate#respond</comments>
		
		<dc:creator><![CDATA[Amar Wadhwani]]></dc:creator>
		<pubDate>Sat, 25 Apr 2026 21:46:41 +0000</pubDate>
				<category><![CDATA[JPA]]></category>
		<category><![CDATA[EntityManager]]></category>
		<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[JPA Annotations]]></category>
		<guid isPermaLink="false">https://www.baeldung.com/hibernate-named-entity-graph</guid>
					<description><![CDATA[<img src="https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-11-1024x536.jpg" class="webfeedsFeaturedVisual wp-post-image" alt="" style="max-width:100% !important;height:auto !important;float: left; margin-right: 5px;" loading="lazy" /><p>Learn how the <em>@NamedEntityGraph</em> annotation works when using Hibernate and different ways to employ it.</p>
The post <a rel="NOFOLLOW" href="https://feeds.feedblitz.com/~/954520139/0/baeldung~A-Guide-to-NamedEntityGraph-in-Hibernate">A Guide to <em>@NamedEntityGraph</em> in Hibernate</a> first appeared on <a rel="NOFOLLOW" href="https://www.baeldung.com">Baeldung</a>.<div style="clear:both;padding-top:0.2em;"><a title="Like on Facebook" href="https://feeds.feedblitz.com/_/28/954520139/baeldung"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Pin it!" href="https://feeds.feedblitz.com/_/29/954520139/baeldung,https%3a%2f%2fwww.baeldung.com%2fwp-content%2fuploads%2f2024%2f07%2fJava-Featured-11-1024x536.jpg"><img height="20" src="https://assets.feedblitz.com/i/pinterest20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Post to X.com" href="https://feeds.feedblitz.com/_/24/954520139/baeldung"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by email" href="https://feeds.feedblitz.com/_/19/954520139/baeldung"><img height="20" src="https://assets.feedblitz.com/i/email20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by RSS" href="https://feeds.feedblitz.com/_/20/954520139/baeldung"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a rel="NOFOLLOW" title="View Comments" href="https://www.baeldung.com/hibernate-named-entity-graph#respond"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/comments20.png"></a>&#160;<a title="Follow Comments via RSS" href="https://www.baeldung.com/hibernate-named-entity-graph/feed"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/commentsrss20.png"></a>&#160;</div>]]>
</description>
										<content:encoded><![CDATA[<img src="https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-11-1024x536.jpg" class="webfeedsFeaturedVisual wp-post-image" alt="" style="float: left; margin-right: 5px;" decoding="async" loading="lazy" srcset="https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-11-1024x536.jpg 1024w, https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-11-300x157.jpg 300w, https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-11-768x402.jpg 768w, https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-11-100x52.jpg 100w, https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-11.jpg 1200w" sizes="auto, (max-width: 580px) 100vw, 580px" /><h2 id="bd-overview" data-id="overview">1. Overview</h2>
<div class="bd-anchor" id="overview"></div>
<p>JPA provides <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/jpa-entity-graph">entity graphs</a> to give us control over entity fetch plans at runtime. However, defining those graphs becomes verbose quickly with deeper association hierarchies.</p>
<p>Hibernate 7 introduces an enhanced Hibernate-specific <em>@NamedEntityGraph</em> annotation (<em>org.hibernate.annotations.NamedEntityGraph</em>) that enables defining entity graphs using a text-based graph language. Instead of nested annotation trees, we define the entity graphs using strings.</p>
<p>In this tutorial, we&#8217;ll explore the <em>@NamedEntityGraph</em> annotation, including a few examples of how it works.</p>
<h2 id="bd-setup" data-id="setup">2. Setup</h2>
<div class="bd-anchor" id="setup"></div>
<p>Before diving into the usage, let&#8217;s prepare the proper environment.</p>
<h3 id="bd-1-hibernate-orm" data-id="1-hibernate-orm">2.1. Hibernate ORM</h3>
<div class="bd-anchor" id="1-hibernate-orm"></div>
<p>To use the new annotation, we need the <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://mvnrepository.com/artifact/org.hibernate.orm/hibernate-core/7.3.1.Final">Hibernate ORM</a> dependency (version 7.0 or later):</p>
<pre><code class="language-xml">&lt;dependency&gt;
    &lt;groupId&gt;org.hibernate.orm&lt;/groupId&gt;
    &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt;
    &lt;version&gt;7.3.1.Final&lt;/version&gt;
    &lt;scope&gt;compile&lt;/scope&gt;
&lt;/dependency&gt;</code></pre>
<p>Next, we set the data model.</p>
<h3 id="bd-2-data-model" data-id="2-data-model">2.2. Data Model</h3>
<div class="bd-anchor" id="2-data-model"></div>
<p>Here, we use the blog domain model from the <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/jpa-entity-graph">JPA tutorial</a>.</p>
<p>Let&#8217;s start with the <em>User</em> entity:</p>
<pre><code class="language-java">@Entity
@Table(name = "app_user")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public class User {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    private String name;
    private String email;
    // standard getters and setters
}</code></pre>
<p><strong>The <em>User</em> entity serves as the base class in a <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/hibernate-inheritance">single-table inheritance hierarchy</a></strong>.</p>
<p>Next, let&#8217;s define an <em>Author</em>, which represents a <em>User</em> who writes posts:</p>
<pre><code class="language-java">@Entity
public class Author extends User {
    private String bio;
    // standard getters and setters
}</code></pre>
<p>Similarly, we define a <em>Moderator</em>, which represents a <em>User</em> who manages the site:</p>
<pre><code class="language-java">@Entity
public class Moderator extends User {
    private String department;
    // standard getters and setters
}</code></pre>
<p>Next, we define the <em>Post</em> entity, which has a <em><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/jpa-hibernate-associations#2-many-to-one-relationship">@ManyToOne</a></em> association to <em>User</em> and a <em><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/jpa-hibernate-associations#1-one-to-many-relationship">@OneToMany</a></em> association to <em>Comment</em>:</p>
<pre><code class="language-">@Entity
public class Post {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    
    private String subject;
    
    @OneToMany(mappedBy = "post")
    private List&lt;Comment&gt; comments = new ArrayList&lt;&gt;();
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn
    private User user;
    // standard getters and setters
}</code></pre>
<p>Finally, the <em>Comment</em> entity references both the <em>Post</em> it belongs to and the <em>User</em> who wrote it:</p>
<pre><code class="language-java">@Entity
public class Comment {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    private String reply;
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn
    private Post post;
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn
    private User user;
    // standard getters and setters
}</code></pre>
<p>At this point, we are ready to explore <em>@NamedEntityGraph</em> in practice.</p>
<h2 id="bd-text-based-graph-language" data-id="text-based-graph-language">3. Text-Based Graph Language</h2>
<div class="bd-anchor" id="text-based-graph-language"></div>
<p><strong>Hibernate enables the creation of entity graphs by parsing a textual representation of a comma-separated list of attributes and subgraph specifications</strong>.</p>
<p>The grammar is fairly straightforward and can be summarized in three points:</p>
<ul>
<li>simple attributes are comma-separated</li>
<li>subgraphs are enclosed in parentheses</li>
<li>nested subgraphs are supported</li>
</ul>
<p>Here, we use this syntax to define the named graphs more concisely.</p>
<h2 id="bd-understanding-namedentitygraph" data-id="understanding-namedentitygraph">4. Understanding <em>@NamedEntityGraph</em></h2>
<div class="bd-anchor" id="understanding-namedentitygraph"></div>
<p>Hibernate offers the <em>@NamedEntityGraph</em> annotation as an alternative to the JPA one, and accepts a graph attribute containing a text representation of a fetch plan.</p>
<h3 id="bd-1-simple-graph" data-id="1-simple-graph">4.1. Simple Graph</h3>
<div class="bd-anchor" id="1-simple-graph"></div>
<p>To fetch, we list the attributes we want using parentheses for subgraphs:</p>
<pre><code class="language-java">@NamedEntityGraph(graph = "subject, user, comments(user)")
@Entity
public class Post {
    // ....
}</code></pre>
<p>Compared to the JPA approach, this is a clear and concise way to define the entity graph, which fetches the subject, user, and comments, and for each comment, also fetches its user. Under the hood, <strong>Hibernate parses the graph definition and builds the same Entity Graph structure that the JPA annotation tree would produce</strong>.</p>
<h3 id="bd-2-defining-multiple-graphs" data-id="2-defining-multiple-graphs">4.2. Defining Multiple Graphs</h3>
<div class="bd-anchor" id="2-defining-multiple-graphs"></div>
<p>Hibernate registers the graph using the entity name by default. However, <strong>we can also name a graph to distinguish it from the others using the <em>name</em> attribute</strong>:</p>
<pre><code class="language-java">@NamedEntityGraph(name = "post-with-comment-users", graph = "subject, user, comments(user)")
@Entity
public class Post {
    // ...
}</code></pre>
<p>Furthermore, we can use the <em>@NamedEntityGraph</em> annotation to define multiple entity graphs on the same entity:</p>
<pre><code class="language-java">@NamedEntityGraph(name = "post-basic", graph = "subject, user, comments")
@NamedEntityGraph(name = "post-with-comment-users", graph = "subject, user, comments(user)")
@NamedEntityGraph(name = "post-with-typed-users", graph = "subject, user(name),
    user(Author: bio), user(Moderator: department)")
@Entity
public class Post {
    // ...
}</code></pre>
<p>Based on the definitions above, we can now use <em>post-basic</em> to fetch only comments without their users, while a detailed page can use post-with-comment-users to load the full comment tree.</p>
<p>Of course, we can also place the annotation at the package level using the <em><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-package-info">package-info.java</a></em> file. However, <strong>the graph string must be prefixed with the entity name</strong>:</p>
<pre><code class="language-java">@org.hibernate.annotations.NamedEntityGraph(name = "package-post-with-comment-users", graph = "Post: subject, user, comments(user)")
package com.baeldung.hibernate.entitygraph.model;</code></pre>
<p>This way, Hibernate can infer which entity the graph belongs to.</p>
<h3 id="bd-3-subtype-specific-subgraphs" data-id="3-subtype-specific-subgraphs">4.3. Subtype-Specific Subgraphs</h3>
<div class="bd-anchor" id="3-subtype-specific-subgraphs"></div>
<p>The text syntax also supports targeting specific subtypes in an inheritance hierarchy. A <em>Post</em> references a<em> User</em>, and Hibernate determines the concrete type at runtime.</p>
<p>To that end, we can target each subtype by prefixing the attributes with the subtype name:</p>
<pre><code class="language-java">@NamedEntityGraph(name = "post-with-typed-user", graph = "subject, user(name), user(Author: bio), user(Moderator: department)")
@Entity
public class Post {
    // ...
}</code></pre>
<p>This graph definition tells Hibernate that the <em>User</em> name is to be fetched in all cases, and if it&#8217;s an <em>Author</em>, fetch its bio, or if it&#8217;s a <em>Moderator</em>, then fetch the department.</p>
<h3 id="bd-4-map-key-subgraphs" data-id="4-map-key-subgraphs">4.4. Map Key Subgraphs</h3>
<div class="bd-anchor" id="4-map-key-subgraphs"></div>
<p>If the attribute is a <em>Map</em> and the map&#8217;s key is itself a managed entity, <strong>we can define a subgraph for the key by appending <em>.key</em> to the attribute name</strong>.</p>
<p>For example, if the Post entity had a <em>Map&lt;User, Comment&gt;</em> attribute called <em>commentsByUser</em>, we can fetch the user name along with the map entry:</p>
<pre><code class="language-">@org.hibernate.annotations.NamedEntityGraph(graph = "commentsByUser.key(name)")</code></pre>
<p><strong>Without the <em>.key</em>, the subgraph would apply to the map value type</strong>, which is <em>Comment</em> in this case.</p>
<h2 id="bd-using-the-graphparser" data-id="using-the-graphparser">5. Using the GraphParser</h2>
<div class="bd-anchor" id="using-the-graphparser"></div>
<p>Hibernate also exposes <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://docs.hibernate.org/orm/8.0/javadocs/org/hibernate/graph/GraphParser.html"><em>GraphParser</em></a>, which enables graph creation at runtime. <strong>The <em>parse()</em>, method accepts an entity class, the graph string, and <em>EntityManager</em></strong>:</p>
<pre><code class="language-java">final EntityGraph&lt;Post&gt; graph = GraphParser
    .parse(Post.class, "subject, user, comments(user)", entityManager);</code></pre>
<p>We can also enrich an existing graph or subgraph at runtime using the <em>parseInto()</em> method:</p>
<pre><code class="language-java">EntityGraph&lt;Post&gt; graph = GraphParser.createEntityGraph(Post.class);
GraphParser.parseInto(graph, "subject, user", entityManger);
GraphParser.parseInto(graph, "comments(user)", entityManger);</code></pre>
<p>Thus, we ensure proper typing.</p>
<h2 id="bd-merging-graphs" data-id="merging-graphs">6. Merging Graphs</h2>
<div class="bd-anchor" id="merging-graphs"></div>
<p>Different aspects of the graph may be defined at multiple parts of an application. <strong>Hibernate enables us to combine multiple entity graphs into a single graph, which is the union of all the graphs using the <em>merge()</em> method</strong>:</p>
<pre><code class="language-java">EntityGraph&lt;Post&gt; mergedGraph = EntityGraphs.merge(entityManager, Post.class,
    entityManager.getEntityGraph("post-basic"),
    entityManager.getEntityGraph("post-with-comment-users"));</code></pre>
<p>The merged graph fetches everything from both graphs into a single query; we could&#8217;ve used the graph string approach as well with the same effect.</p>
<h2 id="bd-using-the-graphs" data-id="using-the-graphs">7. Using the Graphs</h2>
<div class="bd-anchor" id="using-the-graphs"></div>
<p>Once an entity graph has been defined, either at runtime or via an annotation, it needs to be applied to an actual query. There are two possible approaches: one is via the plain JPA <em>EntityManager</em>, as we saw in the JPA tutorial, and the other option is to use Spring Data JPA.</p>
<h3 id="bd-1-using-entitymanager" data-id="1-using-entitymanager">7.1. Using <em>EntityManager</em></h3>
<div class="bd-anchor" id="1-using-entitymanager"></div>
<p>The standard JPA approach uses hints, where <strong>we pass a <em>Map</em>, with either <em>jakarta.persistence.fetchgraph</em> or <em>jakarta.persistence.loadgraph</em> as the key and the <em>EntityGraph</em> object as the value</strong>:</p>
<pre><code class="language-java">EntityGraph&lt;Post&gt; graph = entityManager.getEntityGraph("post-with-comment-users");
        
Map&lt;String, Object&gt; hints = Map.of("jakarta.persistence.fetchgraph", graph);
        
Post post = entityManager.find(Post.class, 1L, hints);</code></pre>
<p>The hint key determines the behaviour; using <em>fetchgraph</em> or <em>loadgraph</em> determines <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/jpa-entity-graph#creating-entity-graph-2">what is loaded</a>.</p>
<p>Importantly, we can apply the same hint either to <em>EntityManager.find()</em> or to a JPQL query.</p>
<h3 id="bd-2-using-spring-data-jpa" data-id="2-using-spring-data-jpa">7.2. Using Spring Data JPA</h3>
<div class="bd-anchor" id="2-using-spring-data-jpa"></div>
<p>Critically, we can skip the hints while using Spring Data JPA. The <em>@EntityGraph</em> annotation handles the wiring internally once we reference the graph by name on a repository method. In addition, we can set the type explicitly:</p>
<pre><code class="language-java">public interface PostRepository extends JpaRepository&lt;Post, Long&gt; {
    @EntityGraph(value = "post-basic", type = EntityGraph.EntityGraphType.LOAD)
    List&lt;Post&gt; findAll(String subject);
    @EntityGraph(value = "post-with-comment-users")
    Post findBySubject(String subject);
}</code></pre>
<p>Otherwise, Hibernate treats the graphs as <em>fetchgraph</em> by default.</p>
<h2 id="bd-testing" data-id="testing">8. Testing</h2>
<div class="bd-anchor" id="testing"></div>
<p>Let&#8217;s explore a few scenarios to verify how these entity graphs work in practice.</p>
<h3 id="bd-1-using-a-named-graph" data-id="1-using-a-named-graph">8.1. Using a Named Graph</h3>
<div class="bd-anchor" id="1-using-a-named-graph"></div>
<p>Let&#8217;s start with a simple named entity graph <em>post-with-comment-users</em> and apply it using <em>fetchgraph</em>:</p>
<pre><code class="language-java">@Test
void whenFindWithFetchGraph_thenAssociationsAreLoaded() {
    EntityManager entityManager = entityManagerFactory.createEntityManager();
    EntityGraph&lt;Post&gt; graph = (EntityGraph&lt;Post&gt;) entityManager.getEntityGraph("post-with-comment-users");
    Post post = entityManager.createQuery("Select p from Post p where p.subject = :subject", Post.class)
        .setParameter("subject", "First Post")
        .setHint("jakarta.persistence.fetchgraph", graph)
        .getSingleResult();
    entityManager.close();
    assertNotNull(post);
    assertEquals("First Post", post.getSubject());
    assertTrue(Hibernate.isInitialized(post.getUser()));
    assertTrue(Hibernate.isInitialized(post.getComments()));
    assertEquals(2, post.getComments().size());
    assertTrue(Hibernate.isInitialized(post.getComments().get(0).getUser()));
    assertTrue(Hibernate.isInitialized(post.getComments().get(1).getUser()));
}</code></pre>
<p>Here, we verify that the named entity graph fetches <em>Post</em> and all its associations, including the commenting <em>User</em>.</p>
<h3 id="bd-2-using-entitymanagerfind" data-id="2-using-entitymanagerfind">8.2. Using EntityManager.<em>find()</em></h3>
<div class="bd-anchor" id="2-using-entitymanagerfind"></div>
<p>On the other hand, we can also apply the same named graph using <em>EntityManager.find()</em>:</p>
<pre><code class="language-java">@Test
void whenFindingByIdWithEntityManagerHints_thenAssociationsAreLoaded() {
    EntityManager entityManager = entityManagerFactory.createEntityManager();
    Long postId = entityManager.createQuery("Select p.id from Post p where p.subject = :subject", Long.class)
        .setParameter("subject", "First Post")
        .getSingleResult();
    EntityGraph&lt;Post&gt; graph = (EntityGraph&lt;Post&gt;) entityManager.getEntityGraph("post-with-comment-users");
    Post post = entityManager.find(Post.class, postId, Map.of("jakarta.persistence.fetchgraph", graph));
    entityManager.close();
    assertNotNull(post);
    assertEquals("First Post", post.getSubject());
    assertTrue(Hibernate.isInitialized(post.getUser()));
    assertTrue(Hibernate.isInitialized(post.getComments()));
    assertEquals(2, post.getComments().size());
    assertTrue(Hibernate.isInitialized(post.getComments().get(0).getUser()));
    assertTrue(Hibernate.isInitialized(post.getComments().get(1).getUser()));
}</code></pre>
<p>This shows that the same graph can be applied using JPA hints outside a JPQL query as well.</p>
<h3 id="bd-3-comparing-multiple-graphs" data-id="3-comparing-multiple-graphs">8.3. Comparing Multiple Graphs</h3>
<div class="bd-anchor" id="3-comparing-multiple-graphs"></div>
<p>Let&#8217;s take a look at how multiple named entity graphs defined on the entity work.</p>
<p>In this case, <strong>we use the <em>post-basic</em> named entity graph and compare it with the <em>post-with-comments-user</em> one</strong>:</p>
<pre><code class="language-java">@Test
void whenUsingPostBasicGraph_thenCommentUsersRemainLazy() {
    EntityManager entityManager = entityManagerFactory.createEntityManager();
    EntityGraph&lt;Post&gt; graph = (EntityGraph&lt;Post&gt;) entityManager.getEntityGraph("post-basic");
    Post post = entityManager.createQuery("Select p from Post p where p.subject = :subject", Post.class)
        .setParameter("subject", "First Post")
        .setHint("jakarta.persistence.fetchgraph", graph)
        .getSingleResult();
    entityManager.close();
    assertNotNull(post);
    assertEquals("First Post", post.getSubject());
    assertTrue(Hibernate.isInitialized(post.getUser()));
    assertTrue(Hibernate.isInitialized(post.getComments()));
    assertFalse(Hibernate.isInitialized(post.getComments().get(0).getUser()));
}</code></pre>
<p>As we can see, the <em>Post</em> and all associations are loaded similarly to the previous example; however, the <em>User</em> for the <em>Comments</em> is lazy.</p>
<h3 id="bd-4-subtype-specific-subgraphs" data-id="4-subtype-specific-subgraphs">8.4. Subtype-Specific Subgraphs</h3>
<div class="bd-anchor" id="4-subtype-specific-subgraphs"></div>
<p>Next, we verify how to fetch the subtype-specific subgraphs.</p>
<p>Specifically, we defined the <em>post-with-typed-user</em> graph:</p>
<pre><code class="language-java">@Test
void whenUsingTypedUserGraph_thenSubtypeAttributesAreLoaded() {
    EntityManager entityManager = entityManagerFactory.createEntityManager();
    EntityGraph&lt;Post&gt; graph = (EntityGraph&lt;Post&gt;) entityManager.getEntityGraph("post-with-typed-user");
    Post authorPost = entityManager.createQuery("Select p from Post p where p.subject = :subject", Post.class)
        .setParameter("subject", "First Post")
        .setHint("jakarta.persistence.fetchgraph", graph)
        .getSingleResult();
    Post moderatorPost = entityManager.createQuery("Select p from Post p where p.subject = :subject", Post.class)
        .setParameter("subject", "Second Post")
        .setHint("jakarta.persistence.fetchgraph", graph)
        .getSingleResult();
    entityManager.close();
    assertNotNull(authorPost);
    assertTrue(Hibernate.isInitialized(authorPost.getUser()));
    assertEquals("Author 1", authorPost.getUser().getName());
    assertInstanceOf(Author.class, authorPost.getUser());
    assertTrue(Hibernate.isPropertyInitialized(authorPost.getUser(), "bio"));
    assertEquals("A Baeldung Author", ((Author) authorPost.getUser()).getBio());
    assertNotNull(moderatorPost);
    assertTrue(Hibernate.isInitialized(moderatorPost.getUser()));
    assertEquals("Moderator 1", moderatorPost.getUser().getName());
    assertInstanceOf(Moderator.class, moderatorPost.getUser());
    assertTrue(Hibernate.isPropertyInitialized(moderatorPost.getUser(), "department"));
    assertEquals("A Baeldung Moderator", ((Moderator) moderatorPost.getUser()).getDepartment());
}</code></pre>
<p>This code should fetch the name for all <em>User</em> types and the bio if it&#8217;s an <em>Author</em> or the department if it&#8217;s a <em>Moderator</em> instance.</p>
<h3 id="bd-5-parsing-graphs-at-runtime" data-id="5-parsing-graphs-at-runtime">8.5. Parsing Graphs at Runtime</h3>
<div class="bd-anchor" id="5-parsing-graphs-at-runtime"></div>
<p>Hibernate also enables us to build graphs at runtime.</p>
<p><strong>When using the <em>parse()</em> method, we can create a new graph</strong>:</p>
<pre><code class="language-java">@Test
void whenParsingGraphsAtRuntime_thenAssociationsAreLoaded() {
    EntityManager entityManager = entityManagerFactory.createEntityManager();
    EntityGraph&lt;Post&gt; parsedGraph = GraphParser.parse(Post.class, "subject, user, comments(user)", entityManager);
    EntityGraph&lt;Post&gt; parsedIntoGraph = entityManager.createEntityGraph(Post.class);
    GraphParser.parseInto(parsedIntoGraph, "subject, user", entityManager);
    GraphParser.parseInto(parsedIntoGraph, "comments(user)", entityManager);
    Post parsedPost = entityManager.createQuery("Select p from Post p where p.subject = :subject", Post.class)
        .setParameter("subject", "First Post")
        .setHint("jakarta.persistence.fetchgraph", parsedGraph)
        .getSingleResult();
    Post parsedIntoPost = entityManager.createQuery("Select p from Post p where p.subject = :subject", Post.class)
        .setParameter("subject", "First Post")
        .setHint("jakarta.persistence.fetchgraph", parsedIntoGraph)
        .getSingleResult();
    entityManager.close();
    assertNotNull(parsedPost);
    assertEquals("First Post", parsedPost.getSubject());
    assertTrue(Hibernate.isInitialized(parsedPost.getUser()));
    assertTrue(Hibernate.isInitialized(parsedPost.getComments()));
    assertEquals(2, parsedPost.getComments().size());
    assertTrue(Hibernate.isInitialized(parsedPost.getComments().get(0).getUser()));
    assertTrue(Hibernate.isInitialized(parsedPost.getComments().get(1).getUser()));
    assertNotNull(parsedIntoPost);
    assertEquals("First Post", parsedIntoPost.getSubject());
    assertTrue(Hibernate.isInitialized(parsedIntoPost.getUser()));
    assertTrue(Hibernate.isInitialized(parsedIntoPost.getComments()));
    assertEquals(2, parsedIntoPost.getComments().size());
    assertTrue(Hibernate.isInitialized(parsedIntoPost.getComments().get(0).getUser()));
    assertTrue(Hibernate.isInitialized(parsedIntoPost.getComments().get(1).getUser()));
}</code></pre>
<p>Notably, <strong>we can enrich an existing graph with the <em>parseInto()</em> method</strong>.</p>
<h3 id="bd-6-merging-graphs" data-id="6-merging-graphs">8.6. Merging Graphs</h3>
<div class="bd-anchor" id="6-merging-graphs"></div>
<p>Finally, we can merge multiple graphs into a single graph:</p>
<pre><code class="language-java">@Test
void whenMergingGraphs_thenUnionOfAttributesIsLoaded() {
    EntityManager entityManager = entityManagerFactory.createEntityManager();
    EntityGraph&lt;Post&gt; basicGraph = (EntityGraph&lt;Post&gt;) entityManager.getEntityGraph("post-basic");
    EntityGraph&lt;Post&gt; postWithCommentUsersGraph = (EntityGraph&lt;Post&gt;) entityManager.getEntityGraph("post-with-comment-users");
    EntityGraph&lt;Post&gt; mergedGraph = EntityGraphs.merge(entityManager, Post.class,
        basicGraph,
        postWithCommentUsersGraph);
    Post post = entityManager.createQuery("Select p from Post p where p.subject = :subject", Post.class)
        .setParameter("subject", "First Post")
        .setHint("jakarta.persistence.fetchgraph", mergedGraph)
        .getSingleResult();
    entityManager.close();
    assertNotNull(post);
    assertEquals("First Post", post.getSubject());
    assertTrue(Hibernate.isInitialized(post.getUser()));
    assertTrue(Hibernate.isInitialized(post.getComments()));
    assertEquals(2, post.getComments().size());
    assertTrue(Hibernate.isInitialized(post.getComments().get(0).getUser()));
    assertTrue(Hibernate.isInitialized(post.getComments().get(1).getUser()));
}</code></pre>
<p>Thus, we get the union of all the merged graphs.</p>
<h2 id="bd-conclusion" data-id="conclusion">9. Conclusion</h2>
<div class="bd-anchor" id="conclusion"></div>
<p>In this article, we explored the <em>@NamedEntityGraph</em> annotation of Hibernate as well as the text-based graph language behind it.</p>
<p>First, we started with simple attribute lists, exploring nested subgraphs and subtype-specific subgraphs. Next, we looked into the <em>GraphParser</em>, which enables parsing graphs at runtime, and the <em>EntityGraph</em> merging of multiple graphs. Finally, we compared how simple, clear, and concise the Hibernate version is as compared to the JPA version.</p>
<p>As always, the code is available <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://github.com/eugenp/tutorials/tree/master/persistence-modules/hibernate-annotations-3">over on GitHub</a>.</p>The post <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/hibernate-named-entity-graph">A Guide to <em>@NamedEntityGraph</em> in Hibernate</a> first appeared on <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com">Baeldung</a>.<Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/954520139/0/baeldung">
<div style="clear:both;padding-top:0.2em;"><a title="Like on Facebook" href="https://feeds.feedblitz.com/_/28/954520139/baeldung"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Pin it!" href="https://feeds.feedblitz.com/_/29/954520139/baeldung,https%3a%2f%2fwww.baeldung.com%2fwp-content%2fuploads%2f2024%2f07%2fJava-Featured-11-1024x536.jpg"><img height="20" src="https://assets.feedblitz.com/i/pinterest20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Post to X.com" href="https://feeds.feedblitz.com/_/24/954520139/baeldung"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by email" href="https://feeds.feedblitz.com/_/19/954520139/baeldung"><img height="20" src="https://assets.feedblitz.com/i/email20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by RSS" href="https://feeds.feedblitz.com/_/20/954520139/baeldung"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a rel="NOFOLLOW" title="View Comments" href="https://www.baeldung.com/hibernate-named-entity-graph#respond"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/comments20.png"></a>&#160;<a title="Follow Comments via RSS" href="https://www.baeldung.com/hibernate-named-entity-graph/feed"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/commentsrss20.png"></a>&#160;</div>]]>
</content:encoded>
					
					<wfw:commentRss>https://feeds.feedblitz.com/~/954520139/0/baeldung~A-Guide-to-NamedEntityGraph-in-Hibernate/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<webfeeds:featuredImage>https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-11-150x150.jpg</webfeeds:featuredImage></item>
<item>
<feedburner:origLink>https://www.baeldung.com/java-weekly-643</feedburner:origLink>
		<title>Java Weekly, Issue 643</title>
		<link>https://feeds.feedblitz.com/~/954364250/0/baeldung~Java-Weekly-Issue</link>
					<comments>https://feeds.feedblitz.com/~/954364250/0/baeldung~Java-Weekly-Issue#respond</comments>
		
		<dc:creator><![CDATA[baeldung]]></dc:creator>
		<pubDate>Thu, 23 Apr 2026 19:26:11 +0000</pubDate>
				<category><![CDATA[Weekly Review]]></category>
		<category><![CDATA[no-ads]]></category>
		<category><![CDATA[no-after-post]]></category>
		<category><![CDATA[no-before-post]]></category>
		<category><![CDATA[no-optins]]></category>
		<guid isPermaLink="false">https://www.baeldung.com/?p=203544</guid>
					<description><![CDATA[<img src="https://www.baeldung.com/wp-content/uploads/2016/10/social-Weekly-Reviews-4.jpg" class="webfeedsFeaturedVisual wp-post-image" alt="" style="max-width:100% !important;height:auto !important;float: left; margin-right: 5px;" loading="lazy" /><p>Interesting AI-focused pieces and starting to look forward towards JDK 27.</p>
The post <a rel="NOFOLLOW" href="https://feeds.feedblitz.com/~/954364250/0/baeldung~Java-Weekly-Issue">Java Weekly, Issue 643</a> first appeared on <a rel="NOFOLLOW" href="https://www.baeldung.com">Baeldung</a>.<div style="clear:both;padding-top:0.2em;"><a title="Like on Facebook" href="https://feeds.feedblitz.com/_/28/954364250/baeldung"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Pin it!" href="https://feeds.feedblitz.com/_/29/954364250/baeldung,https%3a%2f%2fwww.baeldung.com%2fwp-content%2fuploads%2f2016%2f10%2fsocial-Weekly-Reviews-4.jpg"><img height="20" src="https://assets.feedblitz.com/i/pinterest20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Post to X.com" href="https://feeds.feedblitz.com/_/24/954364250/baeldung"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by email" href="https://feeds.feedblitz.com/_/19/954364250/baeldung"><img height="20" src="https://assets.feedblitz.com/i/email20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by RSS" href="https://feeds.feedblitz.com/_/20/954364250/baeldung"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a rel="NOFOLLOW" title="View Comments" href="https://www.baeldung.com/java-weekly-643#respond"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/comments20.png"></a>&#160;<a title="Follow Comments via RSS" href="https://www.baeldung.com/java-weekly-643/feed"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/commentsrss20.png"></a>&#160;</div>]]>
</description>
										<content:encoded><![CDATA[<img src="https://www.baeldung.com/wp-content/uploads/2016/10/social-Weekly-Reviews-4.jpg" class="webfeedsFeaturedVisual wp-post-image" alt="" style="float: left; margin-right: 5px;" decoding="async" loading="lazy" srcset="https://www.baeldung.com/wp-content/uploads/2016/10/social-Weekly-Reviews-4.jpg 952w, https://www.baeldung.com/wp-content/uploads/2016/10/social-Weekly-Reviews-4-300x157.jpg 300w, https://www.baeldung.com/wp-content/uploads/2016/10/social-Weekly-Reviews-4-768x402.jpg 768w" sizes="auto, (max-width: 580px) 100vw, 580px" /><h2 style="text-align: left;" id="bd-spring-and-java" data-id="spring-and-java">1.<strong> Spring and Java</strong></h2>
<div class="bd-anchor" id="spring-and-java"></div>
<p><strong><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://foojay.io/today/distributed-cache-invalidation-patterns/">&gt;&gt; Distributed Cache Invalidation Patterns</a></strong> [<span style="color: #993300;">foojay.io</span>]</p>
<p>A pragmatic tour through distributed cache invalidation, with concrete Spring Boot + Redis code for each pattern. Good brushup.</p>
<h4><strong>Also worth reading:</strong></h4>
<ul>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://foojay.io/today/eliminating-flaky-tests-to-end-world-hunger/" target="_blank" rel="noopener"><strong>Eliminating Flaky Tests to End World Hunger</strong></a> [<span style="color: #800000;">foojay.io</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://foojay.io/today/boxlang-ai-deep-dive-part-3-of-7-multi-agent-orchestration-building-ai-teams-that-work/" target="_blank" rel="noopener"><strong>BoxLang AI Deep Dive — Part 3 of 7: Multi-Agent Orchestration</strong></a> [<span style="color: #800000;">foojay.io</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://foojay.io/today/crossing-the-river-styx-spring-boot-3-5-and-the-zombie-dependency-problem/" target="_blank" rel="noopener"><strong>Crossing the River Styx: Spring Boot 3.5 and the Zombie Dependency Problem</strong></a> [<span style="color: #800000;">foojay.io</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://foojay.io/today/which-java-runtime-should-you-use-in-production-comparing-openjdk-distributions/" target="_blank" rel="noopener"><strong>Which Java Runtime Should You Use in Production? Comparing OpenJDK Distributions</strong></a> [<span style="color: #800000;">foojay.io</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.infoq.com/articles/redesign-pdf-table-extraction/" target="_blank" rel="noopener"><strong>Redesigning Banking PDF Table Extraction: A Layered Approach with Java</strong></a> [<span style="color: #800000;">infoq.com</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.infoq.com/news/2026/04/google-adk-1-0-new-architecture/" target="_blank" rel="noopener"><strong>Google ADK for Java 1.0 Introduces New App and Plugin Architecture</strong></a> [<span style="color: #800000;">infoq.com</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://foojay.io/today/building-a-personalized-content-delivery-system/" target="_blank" rel="noopener"><strong>Building a Personalized Content Delivery System</strong></a> [<span style="color: #800000;">foojay.io</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://inside.java/2026/04/19/generics-optimization/" target="_blank" rel="noopener"><strong>How the JVM Optimizes Generic Code</strong></a> [<span style="color: #800000;">inside.java</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://nipafx.dev/inside-java-newscast-110" target="_blank" rel="noopener"><strong>You Must Avoid Final Field Mutation &#8211; Inside Java Newscast #110</strong></a> [<span style="color: #800000;">nipafx.dev</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://blog.jetbrains.com/kotlin/2026/04/kotlin-professional-certificate-by-jetbrains-now-on-linkedin-learning/" target="_blank" rel="noopener"><strong>Kotlin Professional Certificate by JetBrains – Now on LinkedIn Learning</strong></a> [<span style="color: #800000;">jetbrains.com</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://blog.jetbrains.com/ai/2026/04/introducing-koog-integration-for-spring-ai-smarter-orchestration-for-your-agents/" target="_blank" rel="noopener"><strong>Introducing Koog Integration for Spring AI</strong></a> [<span style="color: #800000;">jetbrains.com</span>]</li>
</ul>
<h4><strong>Webinars and presentations:</strong></h4>
<ul>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://inside.java/2026/04/23/podcast-056/" target="_blank" rel="noopener"><strong>Episode 56 “Ask the Architects at JavaOne” [AtA]</strong></a> [<span style="color: #800000;">inside.java</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://inside.java/2026/04/16/podcast-055/" target="_blank" rel="noopener"><strong>Episode 55 “You Must Avoid Final Field Mutation” [IJN]</strong></a> [<span style="color: #800000;">inside.java</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://spring.io/blog/2026/04/23/a-bootiful-podcast-venkat-james" target="_blank" rel="noopener"><strong>A Bootiful Podcast: Dr. Venkat Subramaniam and James Ward</strong></a> [<span style="color: #800000;">spring.io</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://spring.io/blog/2026/04/20/spring-office-hours-podcast-S5E13" target="_blank" rel="noopener"><strong>Spring Office Hours Podcast: S5E13 &#8211; Community Potluck</strong></a> [<span style="color: #800000;">spring.io</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://spring.io/blog/2026/04/16/a-bootiful-podcast-craig-walls" target="_blank" rel="noopener"><strong>A Bootiful Podcast: the legendary Craig Walls</strong></a> [<span style="color: #800000;">spring.io</span>]</li>
</ul>
<h4><strong>Time to upgrade:</strong></h4>
<ul>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://foojay.io/today/azul-zulu-april-2026-quarterly-update-released/" target="_blank" rel="noopener"><strong>Azul Zulu April 2026 Quarterly Update Released</strong></a> [<span style="color: #800000;">foojay.io</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://in.relation.to/2026/04/23/JPA-4-M2/" target="_blank" rel="noopener"><strong>Jakarta Persistence 4.0 Milestone 2</strong></a> [<span style="color: #800000;">in.relation.to</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://inside.java/2026/04/21/quality-heads-up/" target="_blank" rel="noopener"><strong>Quality Outreach Heads-up &#8211; JDK 27: Obsolete Translation Resources Removed</strong></a> [<span style="color: #800000;">inside.java</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://blog.jetbrains.com/idea/2026/04/intellij-idea-2026-1-1/" target="_blank" rel="noopener"><strong>IntelliJ IDEA 2026.1.1 Is Out!</strong></a> [<span style="color: #800000;">jetbrains.com</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://quarkus.io/blog/quarkus-3-34-6-released/" target="_blank" rel="noopener"><strong>Quarkus 3.34.6</strong></a> and <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://quarkus.io/blog/quarkus-3-34-5-released/" target="_blank" rel="noopener"><strong>3.34.5 &#8211; Maintenance releases</strong></a> [<span style="color: #800000;">quarkus.io</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://spring.io/blog/2026/04/23/spring-boot-3-5-14-available-now" target="_blank" rel="noopener"><strong>Spring Boot 3.5.14</strong></a>, <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://spring.io/blog/2026/04/23/spring-boot-4-0-6-available-now" target="_blank" rel="noopener"><strong>4.0.6</strong></a>, and <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://spring.io/blog/2026/04/23/spring-boot-4-1-0-RC1-available-now" target="_blank" rel="noopener"><strong>4.1.0-RC1 available now</strong></a> [<span style="color: #800000;">spring.io</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://spring.io/blog/2026/04/22/spring-for-apache-pulsar-1-2-17-and-2-0-5-are-now-available" target="_blank" rel="noopener"><strong>Spring for Apache Pulsar 1.2.17 and 2.0.5 are now available</strong></a> [<span style="color: #800000;">spring.io</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://spring.io/blog/2026/04/22/spring-kafka-4" target="_blank" rel="noopener"><strong>Spring for Apache Kafka 4.1.0-RC1, 4.0.5, and 3.3.15 Available</strong></a> [<span style="color: #800000;">spring.io</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://spring.io/blog/2026/04/21/spring-security-releases" target="_blank" rel="noopener"><strong>Spring Security 2026.04 Releases &#8211; Contains CVE Fixes</strong></a> [<span style="color: #800000;">spring.io</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://spring.io/blog/2026/04/21/spring-authorization-server-1-5-7-available-now" target="_blank" rel="noopener"><strong>Spring Authorization Server 1.5.7 Available Now</strong></a> [<span style="color: #800000;">spring.io</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://spring.io/blog/2026/04/17/spring-data-2025-1-5-and-2025-0-11-released" target="_blank" rel="noopener"><strong>Spring Data 2025.1.5 and 2025.0.11 released</strong></a> [<span style="color: #800000;">spring.io</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://spring.io/blog/2026/04/17/spring-data-2026-0-0-goes-RC" target="_blank" rel="noopener"><strong>Spring Data 2026.0.0-RC1 enters release candidate phase</strong></a> [<span style="color: #800000;">spring.io</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://spring.io/blog/2026/04/17/spring-framework-6-2-18-and-7-0-7-available-now" target="_blank" rel="noopener"><strong>Spring Framework 6.2.18 and 7.0.7 Available Now</strong></a> [<span style="color: #800000;">spring.io</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://github.com/eclipse-vertx/vert.x/releases/tag/5.0.11" target="_blank" rel="noopener"><strong>Vert.x 5.0.11</strong></a> [<span style="color: #800000;">github.com/eclipse-vertx</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://github.com/apache/camel/releases/tag/camel-4.14.6" target="_blank" rel="noopener"><strong>Apache Camel 4.14.6</strong></a>, <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://github.com/apache/camel/releases/tag/camel-4.14.7" target="_blank" rel="noopener"><strong>4.14.7</strong></a>, <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://github.com/apache/camel/releases/tag/camel-4.18.2" target="_blank" rel="noopener"><strong>4.18.2</strong></a>, and <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://github.com/apache/camel/releases/tag/camel-4.20.0" target="_blank" rel="noopener"><strong>4.20.0</strong></a> [<span style="color: #800000;">github.com/apache</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://github.com/helidon-io/helidon/releases/tag/3.2.17" target="_blank" rel="noopener"><strong>Helidon 3.2.17</strong></a> [<span style="color: #800000;">github.com/helidon-io</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://github.com/payara/Payara/releases/tag/payara-server-7.2026.4" target="_blank" rel="noopener"><strong>Payara Platform 7.2026.4</strong></a> [<span style="color: #800000;">github.com/payara</span>]</li>
</ul>
<h2 style="text-align: left;" id="bd-technical-amp-musings" data-id="technical-amp-musings">2.<strong> Technical &amp; Musings</strong></h2>
<div class="bd-anchor" id="technical-amp-musings"></div>
<p><strong><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://blog.frankel.ch/illegal-state-unrepresentable/">&gt;&gt; Making illegal state unrepresentable</a></strong> [<span style="color: #993300;">frankel.ch</span>]</p>
<p>A solid take on the classic <em>make illegal states unrepresentable</em> principle, walking through the idea across several languages. Types are still our first line of defense against bad data.</p>
<h4><strong>Also worth reading:</strong></h4>
<ul>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://event-driven.io/en/yoda_principle_in_command_design/" target="_blank" rel="noopener"><strong>Yoda Principle for better integrations</strong></a> [<span style="color: #800000;">event-driven.io</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://blog.jbrains.ca/permalink/playing-well-with-others-an-example" target="_blank" rel="noopener"><strong>Playing Well With Others: An Example</strong></a> [<span style="color: #800000;">jbrains.ca</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.allthingsdistributed.com/2026/04/the-invisible-engineering-behind-lambdas-network.html" target="_blank" rel="noopener"><strong>The invisible engineering behind Lambda&#8217;s network</strong></a> [<span style="color: #800000;">allthingsdistributed.com</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://nurkiewicz.com/2026/04/open-telemetry-glossary.html" target="_blank" rel="noopener"><strong>OpenTelemetry glossary: 30 terms you should know</strong></a> [<span style="color: #800000;">nurkiewicz.com</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://netflixtechblog.com/the-human-infrastructure-how-netflix-built-the-operations-layer-behind-live-at-scale-33e2a311c597" target="_blank" rel="noopener"><strong>The Human Infrastructure: How Netflix Built the Operations Layer Behind Live at Scale</strong></a> [<span style="color: #800000;">netflixtechblog.com</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://netflixtechblog.medium.com/predicting-risk-in-content-launches-how-data-driven-insights-can-transform-launch-planning-587b1f2de928" target="_blank" rel="noopener"><strong>Predicting Risk in Content Launches</strong></a> [<span style="color: #800000;">netflixtechblog.com</span>]</li>
</ul>
<h2 style="text-align: left;" id="bd-pick-of-the-week" data-id="pick-of-the-week">3.<strong> Pick of the Week</strong></h2>
<div class="bd-anchor" id="pick-of-the-week"></div>
<p><strong><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://perthirtysix.com/how-the-heck-does-shazam-work">&gt;&gt; How The Heck Does Shazam Work?</a></strong> [<span style="color: #993300;">perthirtysix.com</span>]</p>The post <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-weekly-643">Java Weekly, Issue 643</a> first appeared on <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com">Baeldung</a>.<Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/954364250/0/baeldung">
<div style="clear:both;padding-top:0.2em;"><a title="Like on Facebook" href="https://feeds.feedblitz.com/_/28/954364250/baeldung"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Pin it!" href="https://feeds.feedblitz.com/_/29/954364250/baeldung,https%3a%2f%2fwww.baeldung.com%2fwp-content%2fuploads%2f2016%2f10%2fsocial-Weekly-Reviews-4.jpg"><img height="20" src="https://assets.feedblitz.com/i/pinterest20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Post to X.com" href="https://feeds.feedblitz.com/_/24/954364250/baeldung"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by email" href="https://feeds.feedblitz.com/_/19/954364250/baeldung"><img height="20" src="https://assets.feedblitz.com/i/email20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by RSS" href="https://feeds.feedblitz.com/_/20/954364250/baeldung"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a rel="NOFOLLOW" title="View Comments" href="https://www.baeldung.com/java-weekly-643#respond"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/comments20.png"></a>&#160;<a title="Follow Comments via RSS" href="https://www.baeldung.com/java-weekly-643/feed"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/commentsrss20.png"></a>&#160;</div>]]>
</content:encoded>
					
					<wfw:commentRss>https://feeds.feedblitz.com/~/954364250/0/baeldung~Java-Weekly-Issue/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<webfeeds:featuredImage>https://www.baeldung.com/wp-content/uploads/2016/10/social-Weekly-Reviews-4-150x150.jpg</webfeeds:featuredImage></item>
<item>
<feedburner:origLink>https://www.baeldung.com/java-keystore-p7b-file-import</feedburner:origLink>
		<title>Importing p7b File to Java Keystore Using Keytool in Java</title>
		<link>https://feeds.feedblitz.com/~/954213383/0/baeldung~Importing-pb-File-to-Java-Keystore-Using-Keytool-in-Java</link>
					<comments>https://feeds.feedblitz.com/~/954213383/0/baeldung~Importing-pb-File-to-Java-Keystore-Using-Keytool-in-Java#respond</comments>
		
		<dc:creator><![CDATA[Vishal Shanbhag]]></dc:creator>
		<pubDate>Wed, 22 Apr 2026 05:02:48 +0000</pubDate>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[KeyStore]]></category>
		<guid isPermaLink="false">https://www.baeldung.com/java-keystore-p7b-file-import</guid>
					<description><![CDATA[<img src="https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-10-1024x536.jpg" class="webfeedsFeaturedVisual wp-post-image" alt="" style="max-width:100% !important;height:auto !important;float: left; margin-right: 5px;" loading="lazy" /><p>Explore how keytool works with certificate bundles in the p7b format.</p>
The post <a rel="NOFOLLOW" href="https://feeds.feedblitz.com/~/954213383/0/baeldung~Importing-pb-File-to-Java-Keystore-Using-Keytool-in-Java">Importing p7b File to Java Keystore Using Keytool in Java</a> first appeared on <a rel="NOFOLLOW" href="https://www.baeldung.com">Baeldung</a>.<div style="clear:both;padding-top:0.2em;"><a title="Like on Facebook" href="https://feeds.feedblitz.com/_/28/954213383/baeldung"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Pin it!" href="https://feeds.feedblitz.com/_/29/954213383/baeldung,https%3a%2f%2fwww.baeldung.com%2fwp-content%2fuploads%2f2024%2f07%2fJava-Featured-10-1024x536.jpg"><img height="20" src="https://assets.feedblitz.com/i/pinterest20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Post to X.com" href="https://feeds.feedblitz.com/_/24/954213383/baeldung"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by email" href="https://feeds.feedblitz.com/_/19/954213383/baeldung"><img height="20" src="https://assets.feedblitz.com/i/email20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by RSS" href="https://feeds.feedblitz.com/_/20/954213383/baeldung"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a rel="NOFOLLOW" title="View Comments" href="https://www.baeldung.com/java-keystore-p7b-file-import#respond"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/comments20.png"></a>&#160;<a title="Follow Comments via RSS" href="https://www.baeldung.com/java-keystore-p7b-file-import/feed"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/commentsrss20.png"></a>&#160;</div>]]>
</description>
										<content:encoded><![CDATA[<img src="https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-10-1024x536.jpg" class="webfeedsFeaturedVisual wp-post-image" alt="" style="float: left; margin-right: 5px;" decoding="async" loading="lazy" srcset="https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-10-1024x536.jpg 1024w, https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-10-300x157.jpg 300w, https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-10-768x402.jpg 768w, https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-10-100x52.jpg 100w, https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-10.jpg 1200w" sizes="auto, (max-width: 580px) 100vw, 580px" /><h2 id="bd-introduction" data-id="introduction">1. Introduction</h2>
<div class="bd-anchor" id="introduction"></div>
<p>When working with production applications in Java, we often find ourselves configuring HTTPS, enabling secure outbound communication, or managing trust stores. <strong><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/keytool-intro">Keytool</a> is the standard tool for working with the required keys and certificates and thus managing Java <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-keystore">keystores</a>.</strong></p>
<p>In this tutorial, we’ll focus on a specific task: importing a <em>p7b</em> certificate file into a Java keystore using keytool.</p>
<h2 id="bd-understanding-the-p7b-pkcs7-format" data-id="understanding-the-p7b-pkcs7-format">2. Understanding the P7B (PKCS#7) Format</h2>
<div class="bd-anchor" id="understanding-the-p7b-pkcs7-format"></div>
<p>Before we dive into the steps to import a P7B file, it&#8217;s worth reviewing and understanding the <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.rfc-editor.org/rfc/rfc2315.html">PKCS#7 format</a>.</p>
<p><strong>In cryptography, PKCS#7 is a standard syntax for storing cryptographically signed or encrypted data</strong>.</p>
<p>One common use for this format is to store SSL certificates. Often, certificate bundles are stored and shared as a <em>.p7b </em>file format.</p>
<h3 id="bd-1-certificate-bundle" data-id="1-certificate-bundle">2.1. Certificate Bundle</h3>
<div class="bd-anchor" id="1-certificate-bundle"></div>
<p>When creating <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-boot-https-self-signed-certificate">self signed</a> certificates for development use, it&#8217;s usually sufficient to have a private key and a self-signed certificate containing the public key. However, when working with production applications that are expected to be available over the internet, we typically need our certificates to be validated by a known Certificate Authority (CA).</p>
<p><strong>Browsers validate a site by validating the site&#8217;s certificate.</strong> Each site presents its own certificate along with information to a chain of intermediate certificates, eventually leading to the root certificate of a CA. Since the browsers trust the CA, any site presenting a validated certificate with a clear chain of certificates leading to a root CA certificate is considered valid.</p>
<p>Once a certificate is validated by a CA, they typically provide a certificate chain consisting of its own root certificate and zero or more intermediate certificates. This certificate chain is provided as a bundle of certificates, sometimes as a <em>.p7b </em>file.</p>
<h3 id="bd-2-the-p7b-format" data-id="2-the-p7b-format">2.2. The P7B Format</h3>
<div class="bd-anchor" id="2-the-p7b-format"></div>
<p><strong>A P7B file is a PKCS#7 container that can store one or more certificates.</strong> It may be encoded either in the binary DER format or in the Base64 PEM format.</p>
<p>When working with Java servers (such as Tomcat), we need to ensure that all the certificates in the bundle are imported into our keystore to prove the validity of our certificate.</p>
<p>Browsers on all modern devices recognise certificates validated by a CA. <strong>During the process of certificate validation, a CA will typically share the signed public certificate for our site along with a certificate chain, aka certificate bundle</strong>.</p>
<p>Sometimes, the certificate bundle comes as a file with a <em>.p7b</em> extension. We note that depending on the encoding, the contents may not be easily readable in a plain text editor. Therefore, we need a few tools to work with these certificates and import them into our keystore.</p>
<h2 id="bd-preparing-a-p7b-file" data-id="preparing-a-p7b-file">3. Preparing a P7B file</h2>
<div class="bd-anchor" id="preparing-a-p7b-file"></div>
<p>Now that we&#8217;ve understood the P7B format, let&#8217;s dive into the process.</p>
<p><strong>Before we can import a certificate bundle, we need a file containing the certificate bundle</strong>. Since we don&#8217;t have a <em>.p7b</em> provided by a CA, we&#8217;ll use the public certificate from <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/">Baeldung.com</a>.</p>
<p>First, we&#8217;ll download the chain and convert it into the P7B file format.</p>
<h3 id="bd-1-downloading-the-certificate-bundle" data-id="1-downloading-the-certificate-bundle">3.1. Downloading the Certificate Bundle</h3>
<div class="bd-anchor" id="1-downloading-the-certificate-bundle"></div>
<p>Most modern browsers allow exporting of certificates to PKCS#7 format encoded files. However, we&#8217;ll do a full command-line interface version using the <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/linux/openssl-command-examples"><em>openssl </em></a>command on a Linux terminal:</p>
<pre><code class="language-shell">$ openssl s_client -connect www.baeldung.com:443 -showcerts &lt;/dev/null</code></pre>
<p>This command prints out several certificates along with some other information about each certificate. Each certificate can be identified easily because of the beginning and ending markers:</p>
<pre><code class="language-shell">-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----</code></pre>
<p>We can now copy each of those certificates (including the markers) and store them as a separate <em>.pem </em>file. So now we have three files <em>site.pem, intermediate.pem and root.pem</em>.</p>
<p>Now let&#8217;s use them to create a <em>.p7b </em>bundle:</p>
<pre><code class="language-shell">$ openssl crl2pkcs7 -nocrl -certfile site.pem -certfile intermediate.pem \
-certfile root.pem -out site-chain.p7b</code></pre>
<p>Finally, we can verify that all certificates of interest are present in the bundle:</p>
<pre><code class="language-shell">$ openssl pkcs7 -print_certs -in site-chain.p7b -noout</code></pre>
<p>We see three certificates printed clearly as expected.</p>
<h3 id="bd-2-the-problem-importing-p7b-file" data-id="2-the-problem-importing-p7b-file">3.2. The Problem Importing P7B file</h3>
<div class="bd-anchor" id="2-the-problem-importing-p7b-file"></div>
<p>Now that we have a valid certificate bundle in the <em>.p7b </em>file format, let&#8217;s check it with <em>keytool</em>:</p>
<pre><code class="language-">$ keytool -printcert -file site-chain.p7b</code></pre>
<p>This command prints information about the three certificates clearly.</p>
<p>Let&#8217;s attempt to import this as-is:</p>
<pre><code class="language-">$ keytool -importcert -file site-chain.p7b -keystore test-keystore.jks -alias site</code></pre>
<p>The output presents an error:</p>
<pre><code class="language-shell">keytool error: java.lang.Exception: Input not an X.509 certificate</code></pre>
<p><strong>The certificate import fails because the <em>keytool -importcert </em>expects the input file to contain exactly one X.509 PEM or DER encoded certificate.</strong></p>
<h2 id="bd-importing-the-p7b-file" data-id="importing-the-p7b-file">4. Importing the P7B file</h2>
<div class="bd-anchor" id="importing-the-p7b-file"></div>
<p>We observe that the direct import of a certificate bundle using keytool can be problematic. <strong>The solution is to break down the bundle into its individual certificates and then import those certificates one by one.</strong></p>
<h3 id="bd-1-converting-to-pem-encoding" data-id="1-converting-to-pem-encoding">4.1. Converting to PEM Encoding</h3>
<div class="bd-anchor" id="1-converting-to-pem-encoding"></div>
<p>To break the bundle into individual PEM files, first, we&#8217;ll convert the bundle from the PKCS #7 to a PEM encoded bundle:</p>
<pre><code class="language-">$ openssl pkcs7 -print_certs -in site-chain.p7b -out site-chain.pem</code></pre>
<p data-start="2455" data-end="2522">This produces a PEM file containing one or more X.509 certificates:</p>
<div class="relative w-full mt-4 mb-1">
<div class="">
<div class="relative">
<div class="h-full min-h-0 min-w-0">
<div class="h-full min-h-0 min-w-0">
<div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl">
<div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback">
<div class="pt-3">
<div class="relative z-0 flex max-w-full">
<div id="code-block-viewer" class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼ5 ͼj" dir="ltr">
<div class="cm-scroller">
<div class="cm-content q9tKkq_readonly">
<pre><code class="language-shell">-----BEGIN CERTIFICATE-----
.......
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
.......
-----END CERTIFICATE-----</code></pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p>We&#8217;re now ready to use <em>keytool</em> to import the certificates.</p>
<h3 id="bd-2-importing-the-pem-bundle" data-id="2-importing-the-pem-bundle">4.2. Importing the PEM Bundle</h3>
<div class="bd-anchor" id="2-importing-the-pem-bundle"></div>
<p><strong>Now that the file is in a format compatible with the <em>keytool</em> import option, we can perform the input</strong>:</p>
<pre><code class="language-">$ keytool -importcert -file site-chain.pem -keystore test-keystore.jks -alias site</code></pre>
<p>This command requires us to set a keystore password and asks us if we trust the certificate. Then the output shows success:</p>
<pre><code class="language-shell">Trust this certificate? [no]:  yes
Certificate was added to keystore</code></pre>
<p>This imports the site&#8217;s certificate under the alias <em>site</em>.</p>
<p><strong>If we need the intermediate and root certificates as well in the same keystore, then we need to import them individually</strong>. From <em>site-chain.pem </em>we can copy each of those certificates (including the begin and end markers) and store them as a separate <em>.pem </em>file. So now we have two more files,<em> intermediate.pem</em> and<em> root.pem</em>.</p>
<p>We can use the same command with different input files and aliases to import the root and intermediate certificates as well:</p>
<pre><code class="language-">$ keytool -importcert -file root.pem -keystore test-keystore.jks -alias root
$ keytool -importcert -file intermediate.pem -keystore test-keystore.jks -alias intermediate</code></pre>
<h3 id="bd-3-verifying-the-import" data-id="3-verifying-the-import">4.3. Verifying the Import</h3>
<div class="bd-anchor" id="3-verifying-the-import"></div>
<p>Now we have all certificates imported, let&#8217;s verify them:</p>
<pre><code class="language-">$ keytool -list -v -keystore test-keystore.jks</code></pre>
<p>This command requests the previously set password and then shows us detailed information about all the imported certificates. At the beginning of the output, we see:</p>
<pre><code class="language-">Keystore type: PKCS12
Keystore provider: SUN
Your keystore contains 3 entries
</code></pre>
<p>That&#8217;s it. Our keystore is now ready to use.</p>
<h2 id="bd-conclusion" data-id="conclusion">5. Conclusion</h2>
<div class="bd-anchor" id="conclusion"></div>
<p>In this article, we explored how keytool works with certificate bundles in the PKCS#7 (<em>.p7b</em>) format. While these files can contain complete certificate chains, they&#8217;re not always directly supported for import.</p>
<p>We learnt that <em>keytool</em> expects X.509 certificates in DER or PEM format, not container formats like PKCS#7. <strong>Converting the <em>.p7b</em> bundle into individual certificates ensures a successful and predictable import process</strong>.</p>The post <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-keystore-p7b-file-import">Importing p7b File to Java Keystore Using Keytool in Java</a> first appeared on <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com">Baeldung</a>.<Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/954213383/0/baeldung">
<div style="clear:both;padding-top:0.2em;"><a title="Like on Facebook" href="https://feeds.feedblitz.com/_/28/954213383/baeldung"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Pin it!" href="https://feeds.feedblitz.com/_/29/954213383/baeldung,https%3a%2f%2fwww.baeldung.com%2fwp-content%2fuploads%2f2024%2f07%2fJava-Featured-10-1024x536.jpg"><img height="20" src="https://assets.feedblitz.com/i/pinterest20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Post to X.com" href="https://feeds.feedblitz.com/_/24/954213383/baeldung"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by email" href="https://feeds.feedblitz.com/_/19/954213383/baeldung"><img height="20" src="https://assets.feedblitz.com/i/email20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by RSS" href="https://feeds.feedblitz.com/_/20/954213383/baeldung"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a rel="NOFOLLOW" title="View Comments" href="https://www.baeldung.com/java-keystore-p7b-file-import#respond"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/comments20.png"></a>&#160;<a title="Follow Comments via RSS" href="https://www.baeldung.com/java-keystore-p7b-file-import/feed"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/commentsrss20.png"></a>&#160;</div>]]>
</content:encoded>
					
					<wfw:commentRss>https://feeds.feedblitz.com/~/954213383/0/baeldung~Importing-pb-File-to-Java-Keystore-Using-Keytool-in-Java/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<webfeeds:featuredImage>https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-10-150x150.jpg</webfeeds:featuredImage></item>
<item>
<feedburner:origLink>https://www.baeldung.com/spring-data-aot-repositories</feedburner:origLink>
		<title>Introduction to Spring Data AOT Repositories</title>
		<link>https://feeds.feedblitz.com/~/954210833/0/baeldung~Introduction-to-Spring-Data-AOT-Repositories</link>
					<comments>https://feeds.feedblitz.com/~/954210833/0/baeldung~Introduction-to-Spring-Data-AOT-Repositories#respond</comments>
		
		<dc:creator><![CDATA[Stelios Anastasakis]]></dc:creator>
		<pubDate>Wed, 22 Apr 2026 04:19:23 +0000</pubDate>
				<category><![CDATA[Spring Data]]></category>
		<category><![CDATA[Spring Data JPA]]></category>
		<guid isPermaLink="false">https://www.baeldung.com/?p=203515</guid>
					<description><![CDATA[<img src="https://www.baeldung.com/wp-content/uploads/2024/11/Persistence-Featured-Image-04-1024x536.jpg" class="webfeedsFeaturedVisual wp-post-image" alt="" style="max-width:100% !important;height:auto !important;float: left; margin-right: 5px;" loading="lazy" /><p>Explore Spring Data AOT Repositories using a simple UserRepository class to demonstrate how Spring Data Repositories worked before and what changes exactly this new feature introduced.</p>
The post <a rel="NOFOLLOW" href="https://feeds.feedblitz.com/~/954210833/0/baeldung~Introduction-to-Spring-Data-AOT-Repositories">Introduction to Spring Data AOT Repositories</a> first appeared on <a rel="NOFOLLOW" href="https://www.baeldung.com">Baeldung</a>.<div style="clear:both;padding-top:0.2em;"><a title="Like on Facebook" href="https://feeds.feedblitz.com/_/28/954210833/baeldung"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Pin it!" href="https://feeds.feedblitz.com/_/29/954210833/baeldung,https%3a%2f%2fwww.baeldung.com%2fwp-content%2fuploads%2f2024%2f11%2fPersistence-Featured-Image-04-1024x536.jpg"><img height="20" src="https://assets.feedblitz.com/i/pinterest20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Post to X.com" href="https://feeds.feedblitz.com/_/24/954210833/baeldung"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by email" href="https://feeds.feedblitz.com/_/19/954210833/baeldung"><img height="20" src="https://assets.feedblitz.com/i/email20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by RSS" href="https://feeds.feedblitz.com/_/20/954210833/baeldung"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a rel="NOFOLLOW" title="View Comments" href="https://www.baeldung.com/spring-data-aot-repositories#respond"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/comments20.png"></a>&#160;<a title="Follow Comments via RSS" href="https://www.baeldung.com/spring-data-aot-repositories/feed"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/commentsrss20.png"></a>&#160;</div>]]>
</description>
										<content:encoded><![CDATA[<img src="https://www.baeldung.com/wp-content/uploads/2024/11/Persistence-Featured-Image-04-1024x536.jpg" class="webfeedsFeaturedVisual wp-post-image" alt="" style="float: left; margin-right: 5px;" decoding="async" loading="lazy" srcset="https://www.baeldung.com/wp-content/uploads/2024/11/Persistence-Featured-Image-04-1024x536.jpg 1024w, https://www.baeldung.com/wp-content/uploads/2024/11/Persistence-Featured-Image-04-300x157.jpg 300w, https://www.baeldung.com/wp-content/uploads/2024/11/Persistence-Featured-Image-04-768x402.jpg 768w, https://www.baeldung.com/wp-content/uploads/2024/11/Persistence-Featured-Image-04-100x52.jpg 100w, https://www.baeldung.com/wp-content/uploads/2024/11/Persistence-Featured-Image-04-600x314.jpg 600w, https://www.baeldung.com/wp-content/uploads/2024/11/Persistence-Featured-Image-04.jpg 1200w" sizes="auto, (max-width: 580px) 100vw, 580px" /><h2 id="bd-overview" data-id="overview">1. Overview</h2>
<div class="bd-anchor" id="overview"></div>
<p>In the last few years, there has been a lot of effort in the Java ecosystem to improve JVM performance. We have seen the <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/graal-java-jit-compiler">JIT compiler</a>, then the <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/ahead-of-time-compilation">Ahead of Time (AoT)</a> Compilation, and lately the Native Images.</p>
<p>Popular Java frameworks, like Micronaut and Spring, have moved in the same direction to achieve better performance through compilation improvements. Spring offers both <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-6-ahead-of-time-optimizations">Ahead of Time</a> and <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-native-intro">Native Image</a> support. However, in such big frameworks, there is still a lot of use of Reflection, so there is still plenty of room for improvement. The latest feature, to be introduced in Spring Boot 4, is an AOT optimization for Spring Data, with the AOT Repositories.</p>
<p>In this article, we&#8217;re going to see what the new feature of Spring Data AOT Repositories brings in. We&#8217;re going to use one of the milestone versions, since this new feature is not offered in any release version yet. Then, we&#8217;ll demonstrate how it works. In the end, we&#8217;re going to compare its usage with the current alternatives, using Spring Boot 3 with and without AOT compilation.</p>
<h2 id="bd-dependencies" data-id="dependencies">2. Dependencies</h2>
<div class="bd-anchor" id="dependencies"></div>
<p>Let&#8217;s start by defining the minimum dependencies possible, for demonstrating the Spring Data AOT Repositories. We can only keep the <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web"><em>spring-boot-starter-web</em></a> and <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa"><em>spring-boot-starter-data-jpa</em></a>. The first is for offering an endpoint to verify that the repository actually works, and the latter contains everything needed for Spring to interact with a database:</p>
<pre><code class="language-xml">&lt;dependency&gt;
    &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
    &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
    &lt;version&gt;4.0.5&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
    &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
    &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
    &lt;version&gt;4.0.5&lt;/version&gt;
&lt;/dependency&gt;</code></pre>
<p>Spring Boot major version 4 is only available in early stages. We&#8217;re still going to use the stable <em>4.0.5</em> for our demonstration.</p>
<h2 id="bd-spring-data-repository" data-id="spring-data-repository">3. Spring Data Repository</h2>
<div class="bd-anchor" id="spring-data-repository"></div>
<p>Moving on, let’s look at how repository implementations have evolved from being runtime proxies to the build-time generated code with Spring Data AOT Repositories. We&#8217;ll use a very simple and popular example of a <em>User</em> entity and the respective <em>UserRepository</em>. This will let us compare behavior and performance across the three options of repositories without AOT, repositories with AOT (but before AOT Repositories), and AOT Repositories.</p>
<h3 id="bd-1-the-domain-model" data-id="1-the-domain-model">3.1. The Domain Model</h3>
<div class="bd-anchor" id="1-the-domain-model"></div>
<p>We’ll use a short <em>User</em> entity, with just three fields, for demonstration purposes:</p>
<pre><code class="language-java">@Entity
@Table(name = "USERS")
public class User {
    @Id
    @GeneratedValue
    private Long id;
    @Column(name = "first_name")
    private String firstName;
    @Column(name = "last_name")
    private String lastName;
    // constructors, setters, getters, equals, etc.
}</code></pre>
<p>The entity class only contains an <em>id</em>, a <em>firstName</em>, and a <em>lastName</em> field. We can use all of the Spring Data and JPA annotations we&#8217;re familiar with. Then we&#8217;ll create the related <em>UserRepository</em>:</p>
<pre><code class="language-java">public interface UserRepository extends Repository&lt;User, Long&gt; {
    User save(User user);
    @Transactional(readOnly = true)
    List&lt;User&gt; findAll();
    List&lt;User&gt; findAllById(Iterable&lt;Long&gt; longs);
    @Query(value = "SELECT * FROM users", nativeQuery = true)
    List&lt;User&gt; nativeQueryFindAllUsers();
    @Query(value = "SELECT u FROM User u")
    List&lt;User&gt; queryFindAllUsers();
}</code></pre>
<p>First, we&#8217;ll include three methods that Spring Data can translate into queries, as normal. On top of that, we&#8217;ll add two more methods annotated with <em>@Query</em>, one native and one non-native. This is so we see how Spring Data AOT Repository handles the different cases.</p>
<p>Second, we extend the <em>Repository</em> Interface to be more generic. The dependency we&#8217;ve included earlier will translate it to <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-data-repositories"><em>JpaRepository</em></a>.</p>
<h3 id="bd-2-spring-data-repositories-without-aot" data-id="2-spring-data-repositories-without-aot">3.2. Spring Data Repositories Without AOT</h3>
<div class="bd-anchor" id="2-spring-data-repositories-without-aot"></div>
<p>Before Spring AOT optimizations and Spring Data AOT Repositories, we would compile the code by using the <em>mvn clean install</em> command. This would convert the Java file to a class, without any changes, except for indentation.</p>
<p>This means that the implementation is not generated. As we know, everything happens at runtime:</p>
<ol>
<li>Spring finds the <em>Repository</em> interfaces</li>
<li>Passes them to the <em>JpaRepositoryFactory</em></li>
<li>The <em>JpaRepositoryFactory</em> builds the <em>SimpleJpaRepository</em> instances</li>
<li>Then wraps each instance with a dynamic proxy that routes calls from your interface methods, like <em>findAll()</em>, to the corresponding methods on <em>SimpleJpaRepository</em>, or to the <em>Query</em> and <em>JPQL</em> implementations, or to any custom implementations</li>
</ol>
<p><strong>Everything is being built at runtime, based on reflection</strong>. This means that startup time and memory are being affected.</p>
<h3 id="bd-3-repositories-with-aot-before-spring-data-aot-repositories" data-id="3-repositories-with-aot-before-spring-data-aot-repositories">3.3. Repositories With AOT, Before Spring Data AOT Repositories</h3>
<div class="bd-anchor" id="3-repositories-with-aot-before-spring-data-aot-repositories"></div>
<p>Spring 6 came with Ahead of Time Optimizations. To <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-6-ahead-of-time-optimizations#1-aot-optimization">enable this feature</a>, we need to:</p>
<ul>
<li>Compile the code, including the <em>spring-boot:process-aot</em> task, or set up the build plugin to enable AOT compilation by default</li>
<li>Execute the application setting the <em>spring.aot.enabled</em> property to <em>true</em></li>
</ul>
<p>Regarding the Spring Data Repositories, the result is the same as before. This means that we get the same class, and then Spring uses the <em>SimpleJpaRepository</em>, reflection, and proxies at runtime to make everything happen. <strong>The difference is that the AOT compilation creates an additional class, the <em>UserRepository__BeanDefinitions</em> class, with some reflection metadata and other info precomputed at build time. This improves startup time</strong>.</p>
<h3 id="bd-4-spring-data-aot-repositories" data-id="4-spring-data-aot-repositories">3.4. Spring Data AOT Repositories</h3>
<div class="bd-anchor" id="4-spring-data-aot-repositories"></div>
<p>The new feature, coming with Spring Data 4, is the Spring Data AOT Repositories. With this feature, Spring is shifting all the Repository preparations that are done at application startup to build time.</p>
<p>Let&#8217;s see how this works, on a high level. <strong>Spring turns your Repository query methods into actual source code by relying on the store-specific nature of the repository</strong>. The methods that are already implemented are used directly. For instance, the <em>save()</em> method is implemented in <em>SimpleJpaRepository</em>, in our example. Spring doesn&#8217;t need to generate any code for such methods. However, the remaining methods will be implemented inside the <em>UserRepositoryImpl__AotRepository</em> class.</p>
<p>The way to compile the code using AOT remains the same as in the previous Spring version. We can find the generated classes in our <em>target/classes</em> folder:</p>
<pre><code class="language-java">@Generated
public class UserRepositoryImpl__AotRepository extends AotRepositoryFragmentSupport {
    private final RepositoryFactoryBeanSupport.FragmentCreationContext context;
    private final EntityManager entityManager;
    public List&lt;User&gt; nativeQueryFindAllUsers() {
        String var1 = "SELECT * FROM users";
        Query var2 = this.entityManager.createNativeQuery(var1, User.class);
        return var2.getResultList();
    }
    public List&lt;User&gt; queryFindAllUsers() {
        String var1 = "SELECT u FROM User u";
        Query var2 = this.entityManager.createQuery(var1);
        return var2.getResultList();
    }
}</code></pre>
<p><strong>Methods annotated with <em>@Query</em> contain the same code we would write if we weren&#8217;t using Spring Data</strong>. The <em>UserRepository__BeanDefinitions</em> class is present, similar to previous versions. The last source generated by this new feature is a JSON file with hints for native-image, <em>UserRepository.json</em>.</p>
<p><strong>This way Spring generates a concrete repository implementation at build time, eliminating the proxy and most runtime reflection. This improves both the startup time and memory</strong>.</p>
<p>To enable usage of Spring Data AOT Repositories, we need to execute the application setting the <em>spring.aot.repositories.enabled</em> property to <em>true:</em></p>
<pre><code class="language-bash">mvn spring-boot:run -Dspring.aot.enabled=true -Dspring.aot.repositories.enabled=true</code></pre>
<h2 id="bd-performance-implications" data-id="performance-implications">4. Performance Implications</h2>
<div class="bd-anchor" id="performance-implications"></div>
<p>Spring Data AOT Repositories are expected to improve application performance. Startup time should be reduced, and some memory consumption as well, as advertised in the relevant <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://spring.io/blog/2025/05/22/spring-data-ahead-of-time-repositories">Spring Blog article</a>:</p>
<a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/wp-content/uploads/2026/04/spring-petclinic-jpa-aot-repositories-benchmark-green_theme.png"><img decoding="async" class="alignnone size-large wp-image-242852" src="https://www.baeldung.com/wp-content/uploads/2026/04/spring-petclinic-jpa-aot-repositories-benchmark-green_theme-1024x229.png" alt="spring data aot repositories benchmark" /></a>
<p>Next, we&#8217;ll compare the performance of the three implementations we discussed so far:</p>
<ul>
<li>Spring before AOT, using the <em>java -jar spring-data-jpa-not-aot/target/spring-data-jpa-not-aot-0.0.1-SNAPSHOT.jar</em> command</li>
<li>Spring with AOT improvements, using the <em>java -Dspring.aot.enabled=true -jar spring-data-jpa-aot/target/spring-data-jpa-aot-0.0.1-SNAPSHOT.jar</em> command</li>
<li>Spring Data AOT Repositories, using the <em>java -Dspring.aot.enabled=true -Dspring.aot.repositories.enabled=true -jar spring-data-jpa-aot-repository/target/spring-data-jpa-aot-repository-0.0.1-SNAPSHOT.jar</em> command</li>
</ul>
<p>We&#8217;ll use five entity classes and repositories to try to make the changes more visible. And we&#8217;ll focus on the startup time and memory consumption.</p>
<h3 id="bd-1-build-times-comparison" data-id="1-build-times-comparison">4.1. Build Times Comparison</h3>
<div class="bd-anchor" id="1-build-times-comparison"></div>
<p>As already explained, the new AOT Repositories feature performs additional work at build time to construct the Repositories. So, this means that we expect slower build times when we enable this feature:</p>
<ul>
<li>repositories without AOT: <em>Total time: 11.076 s</em></li>
<li>repositories with AOT: <em>Total time: 17.166 s</em></li>
<li>AOT Repositories: <em>Total time: 25.390 s</em></li>
</ul>
<p><strong>With Spring Data AOT Repositories, if we have syntax errors in JPA methods, we see compile-time errors.</strong> This makes sense, since the transformation of JPA methods to SQL Statements now happens at compile rather than runtime.</p>
<h3 id="bd-2-startup-times-comparison" data-id="2-startup-times-comparison">4.2. Startup Times Comparison</h3>
<div class="bd-anchor" id="2-startup-times-comparison"></div>
<p>Next, we&#8217;ll execute a script that starts each service, and at the same time, it starts trying to hit an endpoint that uses a repository. This way, we can monitor how long it took for the service to start, since the server and the repositories are ready for use.</p>
<p>For the repositories without AOT, the script output was:</p>
<pre><code class="language-less">==== RESULTS ====
time elapsed 10148 millis
Process Specific Memory/CPU (RSS KB / CPU Time): 289840 00:00:28</code></pre>
<p>For the repositories with AOT:</p>
<pre><code class="language-less">==== RESULTS ====
time elapsed 9885 millis
Process Specific Memory/CPU (RSS KB / CPU Time): 291104 00:00:25</code></pre>
<p>And for Spring Data AOT Repositories:</p>
<pre><code class="language-less">==== RESULTS ====
time elapsed 8745 millis
Process Specific Memory/CPU (RSS KB / CPU Time): 292864 00:00:23</code></pre>
<p>This makes perfect sense, since we know that AOT and AOT Repositories target the improvement of startup times. And this is clear even for small projects like ours.</p>
<p>The memory improvement that is advertised by Spring is not shown here, but it makes sense for our small project.</p>
<p>Note, when starting the application without AOT, we should notice a log saying: <em>Starting Application</em>. But when using AOT, it should say <em>Starting AOT-processed Application</em>.</p>
<h3 id="bd-3-comparison-under-load" data-id="3-comparison-under-load">4.3. Comparison Under Load</h3>
<div class="bd-anchor" id="3-comparison-under-load"></div>
<p>Our last test includes a script that sends some traffic to each implementation and compares the performance.</p>
<p>For the repositories without AOT, the script output was:</p>
<pre><code class="language-less">==== RESULTS ====
Total requests: 6688
Success (2xx): 6688
...
Avg duration (measured): 51.7629ms
...
Max memory utilised: 331888</code></pre>
<p>For the repositories with AOT:</p>
<pre><code class="language-less">==== RESULTS ====
Total requests: 7664
Success (2xx): 7664
...
Avg duration (measured): 43.934ms
...
Max memory utilised: 334000</code></pre>
<p>And for Spring Data AOT Repositories:</p>
<pre><code class="language-less">==== RESULTS ====
Total requests: 6673
Success (2xx): 6673
...
Avg duration (measured): 49.0766ms
...
Max memory utilised: 337948</code></pre>
<p><strong>The result doesn&#8217;t show the memory improvement that Spring advertises, but this could be impacted by the project sizes and the data store</strong>.</p>
<h2 id="bd-conclusion" data-id="conclusion">5. Conclusion</h2>
<div class="bd-anchor" id="conclusion"></div>
<p>In this article, we explored the new feature of Spring Boot 4, Spring Data AOT Repositories. We used a simple <em>UserRepository</em> class to demonstrate how Spring Data Repository worked before and what changes exactly this new feature introduced. Finally, we compared the performance implications of using the Spring Data AOT Repositories.</p>
<p>As always, the source code of the examples can be found <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~github.com/eugenp/tutorials/tree/master/persistence-modules/spring-data-jpa-repo-5/">over on GitHub</a>.</p>The post <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/spring-data-aot-repositories">Introduction to Spring Data AOT Repositories</a> first appeared on <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com">Baeldung</a>.<Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/954210833/0/baeldung">
<div style="clear:both;padding-top:0.2em;"><a title="Like on Facebook" href="https://feeds.feedblitz.com/_/28/954210833/baeldung"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Pin it!" href="https://feeds.feedblitz.com/_/29/954210833/baeldung,https%3a%2f%2fwww.baeldung.com%2fwp-content%2fuploads%2f2024%2f11%2fPersistence-Featured-Image-04-1024x536.jpg"><img height="20" src="https://assets.feedblitz.com/i/pinterest20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Post to X.com" href="https://feeds.feedblitz.com/_/24/954210833/baeldung"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by email" href="https://feeds.feedblitz.com/_/19/954210833/baeldung"><img height="20" src="https://assets.feedblitz.com/i/email20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by RSS" href="https://feeds.feedblitz.com/_/20/954210833/baeldung"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a rel="NOFOLLOW" title="View Comments" href="https://www.baeldung.com/spring-data-aot-repositories#respond"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/comments20.png"></a>&#160;<a title="Follow Comments via RSS" href="https://www.baeldung.com/spring-data-aot-repositories/feed"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/commentsrss20.png"></a>&#160;</div>]]>
</content:encoded>
					
					<wfw:commentRss>https://feeds.feedblitz.com/~/954210833/0/baeldung~Introduction-to-Spring-Data-AOT-Repositories/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<webfeeds:featuredImage>https://www.baeldung.com/wp-content/uploads/2024/11/Persistence-Featured-Image-04-150x150.jpg</webfeeds:featuredImage></item>
<item>
<feedburner:origLink>https://www.baeldung.com/java-ipv4-ipv6-conversion</feedburner:origLink>
		<title>Convert IPv4 to IPv6 Address in Java</title>
		<link>https://feeds.feedblitz.com/~/954210836/0/baeldung~Convert-IPv-to-IPv-Address-in-Java</link>
					<comments>https://feeds.feedblitz.com/~/954210836/0/baeldung~Convert-IPv-to-IPv-Address-in-Java#respond</comments>
		
		<dc:creator><![CDATA[Ali Imran Nagori]]></dc:creator>
		<pubDate>Wed, 22 Apr 2026 04:14:40 +0000</pubDate>
				<category><![CDATA[Networking]]></category>
		<category><![CDATA[IP Address]]></category>
		<category><![CDATA[String Conversions]]></category>
		<guid isPermaLink="false">https://www.baeldung.com/java-ipv4-ipv6-conversion</guid>
					<description><![CDATA[<img src="https://www.baeldung.com/wp-content/uploads/2016/10/social-Core-Java-1.jpg" class="webfeedsFeaturedVisual wp-post-image" alt="almost done featured" style="max-width:100% !important;height:auto !important;float: left; margin-right: 5px;" loading="lazy" /><p>Learn how to use Java for converting between IPv4 and IPv6 addresses.</p>
The post <a rel="NOFOLLOW" href="https://feeds.feedblitz.com/~/954210836/0/baeldung~Convert-IPv-to-IPv-Address-in-Java">Convert IPv4 to IPv6 Address in Java</a> first appeared on <a rel="NOFOLLOW" href="https://www.baeldung.com">Baeldung</a>.<div style="clear:both;padding-top:0.2em;"><a title="Like on Facebook" href="https://feeds.feedblitz.com/_/28/954210836/baeldung"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Pin it!" href="https://feeds.feedblitz.com/_/29/954210836/baeldung,https%3a%2f%2fwww.baeldung.com%2fwp-content%2fuploads%2f2016%2f10%2fsocial-Core-Java-1.jpg"><img height="20" src="https://assets.feedblitz.com/i/pinterest20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Post to X.com" href="https://feeds.feedblitz.com/_/24/954210836/baeldung"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by email" href="https://feeds.feedblitz.com/_/19/954210836/baeldung"><img height="20" src="https://assets.feedblitz.com/i/email20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by RSS" href="https://feeds.feedblitz.com/_/20/954210836/baeldung"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a rel="NOFOLLOW" title="View Comments" href="https://www.baeldung.com/java-ipv4-ipv6-conversion#respond"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/comments20.png"></a>&#160;<a title="Follow Comments via RSS" href="https://www.baeldung.com/java-ipv4-ipv6-conversion/feed"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/commentsrss20.png"></a>&#160;</div>]]>
</description>
										<content:encoded><![CDATA[<img src="https://www.baeldung.com/wp-content/uploads/2016/10/social-Core-Java-1.jpg" class="webfeedsFeaturedVisual wp-post-image" alt="almost done featured" style="float: left; margin-right: 5px;" decoding="async" loading="lazy" srcset="https://www.baeldung.com/wp-content/uploads/2016/10/social-Core-Java-1.jpg 952w, https://www.baeldung.com/wp-content/uploads/2016/10/social-Core-Java-1-300x157.jpg 300w, https://www.baeldung.com/wp-content/uploads/2016/10/social-Core-Java-1-768x402.jpg 768w" sizes="auto, (max-width: 580px) 100vw, 580px" /><h2 id="bd-overview" data-id="overview">1. Overview</h2>
<div class="bd-anchor" id="overview"></div>
<p>Internet Protocol version 6 or IPv6, defined in RFC 2460, is the latest generation of the <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/cs/popular-network-protocols#internet-protocol-ip">Internet Protocol</a>. It replaces the limited IPv4 address space. However, <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/cs/ipv4-vs-ipv6#ipv6">IPv6</a> doesn&#8217;t directly interoperate with <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/cs/ipv4-datagram#ipv4-datagram">IPv4</a>. Because of this, devices using different protocols often face compatibility issues.</p>
<p>To solve this, modern systems use techniques like dual-stack, tunneling, and translation. Thus, these methods enable systems to support IPv6 while still working with IPv4. However, <strong>they primarily work at the <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/cs/osi-transport-vs-networking-layer#services-of-network-layer">Network Layer</a> (Layer 3)</strong>.</p>
<p>In many cases, developers need a way to represent IPv4 addresses in an IPv6-compatible format. So, they write code to map data between the two formats.</p>
<p>In this tutorial, we see how to convert an IPv4 address to IPv6 using <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/get-started-with-java-series">Java</a>.</p>
<h2 id="bd-what-does-converting-mean" data-id="what-does-converting-mean">2. What Does Converting Mean?</h2>
<div class="bd-anchor" id="what-does-converting-mean"></div>
<p>In reality, <strong>there is no direct conversion from IPv4 to IPv6</strong>. The two protocols differ in structure and design.</p>
<p>Instead, a common approach is to embed IPv4 inside IPv6. This format is called an IPv4-mapped IPv6 address.</p>
<p>In addition, we also have other representations. However, not all are standard today. For example, <strong>IPv4-compatible IPv6 addresses are now deprecated</strong>. In the same way, <em>NAT64</em> and <em>6to4</em> act as transition methods, not true conversions.</p>
<p>So, let&#8217;s look at how to implement the above techniques in Java.</p>
<h2 id="bd-java-implementation" data-id="java-implementation">3. Java Implementation</h2>
<div class="bd-anchor" id="java-implementation"></div>
<p>In essence, Java provides built-in classes to work with IP addresses. The <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-get-ip-url#1-using-the-inetaddress-class"><em>InetAddress</em></a> class supports both IPv4 and IPv6.</p>
<h3 id="bd-1-convert-ipv4-to-ipv6-mapped-address" data-id="1-convert-ipv4-to-ipv6-mapped-address">3.1. Convert IPv4 to IPv6-Mapped Address</h3>
<div class="bd-anchor" id="1-convert-ipv4-to-ipv6-mapped-address"></div>
<p>Let&#8217;s look at the case of a mapped address.</p>
<p>For that, we convert an IPv4 address to an IPv6 format using a standard format:</p>
<pre><code class="language-plaintext">::ffff:w.x.y.z</code></pre>
<p>In the above case, <em>w.x.y.z</em> is the target IPv4 address:</p>
<pre><code class="language-java">String toIpv4MappedIpv6(String ipv4Address) throws UnknownHostException {
    validateIpv4(ipv4Address);
    return "::ffff:" + ipv4Address;
}</code></pre>
<p><strong>This method simply adds the <em>::ffff:</em> prefix</strong>. As a result, we get a valid IPv4-mapped IPv6 address.</p>
<h3 id="bd-2-ipv4-compatible-ipv6-address" data-id="2-ipv4-compatible-ipv6-address">3.2. IPv4-Compatible IPv6 Address</h3>
<div class="bd-anchor" id="2-ipv4-compatible-ipv6-address"></div>
<p>Markedly, the IPv4-compatible IPv6 address format is no longer in use. Still, it helps to understand older systems.</p>
<p><strong>In hex notation, this type of address sets all the leading bits to zero</strong>.</p>
<p>Let&#8217;s again take the IPv4 address <em>w.x.y.z</em>:</p>
<pre><code class="language-plaintext">0000:0000:0000:0000:0000:0000:WWXX:YYZZ</code></pre>
<p>This address can also be compressed by omitting all leading zeroes:</p>
<pre><code class="language-plaintext">::w.x.y.z </code></pre>
<p>Furthermore, we see its implementation:</p>
<pre><code class="language-java">String toIpv4CompatibleIpv6(String ipv4Address) throws UnknownHostException {
    validateIpv4(ipv4Address);
    return "::" + ipv4Address;
}</code></pre>
<p>The above method takes an IPv4 address and returns an IPv6 address.</p>
<p>As a result, an IPv4 address, <em>192.0.2.33</em>, returns IPv4-compatible IPv6 <em>::192.0.2.33.</em></p>
<h3 id="bd-3-nat64-implementation" data-id="3-nat64-implementation">3.3. NAT64 Implementation</h3>
<div class="bd-anchor" id="3-nat64-implementation"></div>
<p>NAT64-style translated addresses typically use a <em>64:ff9b::/96</em> prefix. It&#8217;s then followed by the target IPv4 address.</p>
<p>For example, <strong>an IP address of the form <em>w.x.y.z</em> gets the NAT64 ID <em>64:ff9b::w.x.y.z</em></strong>.</p>
<p>The implementation code remains the same as the last ones:</p>
<pre><code class="language-java">String toNat64Ipv6(String ipv4Address) throws UnknownHostException {
    validateIpv4(ipv4Address);
    return "64:ff9b::" + ipv4Address;
}</code></pre>
<p>Thus, if we have an IPv4 address of <em>192.0.2.33</em>, the resulting address should be <em>64:ff9b::192.0.2.33</em>.</p>
<h3 id="bd-4-6to4-addresses-tunneling" data-id="4-6to4-addresses-tunneling">3.4. <em>6to4</em> Addresses (Tunneling)</h3>
<div class="bd-anchor" id="4-6to4-addresses-tunneling"></div>
<p><em>6to4</em> is a transition method. <strong>It wraps IPv6 packets inside IPv4 packets</strong>. Moreover, for this purpose, Internet Assigned Numbers Authority (<a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.iana.org/">IANA</a>) has assigned the <em>2002::/16</em> block.</p>
<p>For example, the IPv4 address <em>192.0.2.4</em> has a hexadecimal equivalent of <em>C000:0204</em>. <strong>The <em>6to4</em> prefix in this case becomes <em>2002:C000:0204::/48</em></strong>:</p>
<pre><code class="language-java">16 bits (the base) + 32 bits (the IPv4) = 48 bits</code></pre>
<p>Thus, the prefix <em>2002::/16</em> is followed by the <em>32</em> bits of the public IPv4 address.</p>
<p>Let&#8217;s see its Java implementation:</p>
<pre><code class="language-java">String toSixToFourIpv6(String ipv4Address) throws UnknownHostException {
    byte[] bytes = validateAndGetBytes(ipv4Address);
    return String.format("2002:%02x%02x:%02x%02x::",
      bytes[0] &amp; 0xff,
      bytes[1] &amp; 0xff,
      bytes[2] &amp; 0xff,
      bytes[3] &amp; 0xff);
}</code></pre>
<p>The above method converts each IPv4 byte into its hexadecimal representation.</p>
<p>Finally, the result gets appended to the <em>2002::/16</em> prefix.</p>
<h2 id="bd-junit-test" data-id="junit-test">4. JUnit Test</h2>
<div class="bd-anchor" id="junit-test"></div>
<p>To verify the class methods, we can write a simple JUnit test:</p>
<pre><code class="language-java">class Ipv4ToIpv6ConverterUnitTest {
    private final Ipv4ToIpv6Converter converter = new Ipv4ToIpv6Converter();
    @Test
    void whenValidIpv4_thenReturnMappedIpv6() throws Exception {
        String result = converter.toIpv4MappedIpv6("192.168.1.1");
        assertEquals("::ffff:192.168.1.1", result);
    }
}</code></pre>
<p>Thus, we can check if the output matches the expected value. In the same way, we can write tests for other methods.</p>
<h2 id="bd-use-cases" data-id="use-cases">5. Use Cases</h2>
<div class="bd-anchor" id="use-cases"></div>
<p>IPv4-mapped IPv6 addresses help both protocols work together in dual-stack systems.</p>
<p>Users can also use a tunneling mechanism, like <em>6to4</em>, if they don&#8217;t have dual-stack support.</p>
<p>Similarly, we have translators like NAT64. They also help in interoperability between an IPv4 device and an IPv6 device.</p>
<p>The general idea of the conversion is to enable the different protocols to work in sync.</p>
<h2 id="bd-conclusion" data-id="conclusion">6. Conclusion</h2>
<div class="bd-anchor" id="conclusion"></div>
<p>In this article, we discussed the conversion between IPv4 and IPv6 with Java. Since both IP protocols differ in structure and semantics, we can&#8217;t truly convert IPv4 into IPv6.</p>
<p>Because of this, <strong>the above approaches don&#8217;t turn an IPv4 host into a native IPv6 host</strong>. Instead, they provide a way for the systems to work together. Java simplifies this process through classes like InetAddress and byte handling.</p>
<p>As a result, applications can support both address formats efficiently.</p>
<p>The complete code for this article is available <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://github.com/eugenp/tutorials/tree/master/core-java-modules/core-java-networking-5">over on GitHub</a>.</p>The post <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-ipv4-ipv6-conversion">Convert IPv4 to IPv6 Address in Java</a> first appeared on <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com">Baeldung</a>.<Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/954210836/0/baeldung">
<div style="clear:both;padding-top:0.2em;"><a title="Like on Facebook" href="https://feeds.feedblitz.com/_/28/954210836/baeldung"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Pin it!" href="https://feeds.feedblitz.com/_/29/954210836/baeldung,https%3a%2f%2fwww.baeldung.com%2fwp-content%2fuploads%2f2016%2f10%2fsocial-Core-Java-1.jpg"><img height="20" src="https://assets.feedblitz.com/i/pinterest20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Post to X.com" href="https://feeds.feedblitz.com/_/24/954210836/baeldung"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by email" href="https://feeds.feedblitz.com/_/19/954210836/baeldung"><img height="20" src="https://assets.feedblitz.com/i/email20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by RSS" href="https://feeds.feedblitz.com/_/20/954210836/baeldung"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a rel="NOFOLLOW" title="View Comments" href="https://www.baeldung.com/java-ipv4-ipv6-conversion#respond"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/comments20.png"></a>&#160;<a title="Follow Comments via RSS" href="https://www.baeldung.com/java-ipv4-ipv6-conversion/feed"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/commentsrss20.png"></a>&#160;</div>]]>
</content:encoded>
					
					<wfw:commentRss>https://feeds.feedblitz.com/~/954210836/0/baeldung~Convert-IPv-to-IPv-Address-in-Java/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<webfeeds:featuredImage>https://www.baeldung.com/wp-content/uploads/2016/10/social-Core-Java-1-150x150.jpg</webfeeds:featuredImage></item>
<item>
<feedburner:origLink>https://www.baeldung.com/java-weekly-642</feedburner:origLink>
		<title>Java Weekly, Issue 642</title>
		<link>https://feeds.feedblitz.com/~/953941595/0/baeldung~Java-Weekly-Issue</link>
					<comments>https://feeds.feedblitz.com/~/953941595/0/baeldung~Java-Weekly-Issue#respond</comments>
		
		<dc:creator><![CDATA[baeldung]]></dc:creator>
		<pubDate>Fri, 17 Apr 2026 10:45:25 +0000</pubDate>
				<category><![CDATA[Weekly Review]]></category>
		<category><![CDATA[no-ads]]></category>
		<category><![CDATA[no-after-post]]></category>
		<category><![CDATA[no-before-post]]></category>
		<category><![CDATA[no-optins]]></category>
		<guid isPermaLink="false">https://www.baeldung.com/?p=203498</guid>
					<description><![CDATA[<img src="https://www.baeldung.com/wp-content/uploads/2016/10/social-Weekly-Reviews-4.jpg" class="webfeedsFeaturedVisual wp-post-image" alt="" style="max-width:100% !important;height:auto !important;float: left; margin-right: 5px;" loading="lazy" /><p>Interesting AI-focused pieces and starting to look forward towards JDK 27.</p>
The post <a rel="NOFOLLOW" href="https://feeds.feedblitz.com/~/953941595/0/baeldung~Java-Weekly-Issue">Java Weekly, Issue 642</a> first appeared on <a rel="NOFOLLOW" href="https://www.baeldung.com">Baeldung</a>.<div style="clear:both;padding-top:0.2em;"><a title="Like on Facebook" href="https://feeds.feedblitz.com/_/28/953941595/baeldung"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Pin it!" href="https://feeds.feedblitz.com/_/29/953941595/baeldung,https%3a%2f%2fwww.baeldung.com%2fwp-content%2fuploads%2f2016%2f10%2fsocial-Weekly-Reviews-4.jpg"><img height="20" src="https://assets.feedblitz.com/i/pinterest20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Post to X.com" href="https://feeds.feedblitz.com/_/24/953941595/baeldung"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by email" href="https://feeds.feedblitz.com/_/19/953941595/baeldung"><img height="20" src="https://assets.feedblitz.com/i/email20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by RSS" href="https://feeds.feedblitz.com/_/20/953941595/baeldung"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a rel="NOFOLLOW" title="View Comments" href="https://www.baeldung.com/java-weekly-642#respond"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/comments20.png"></a>&#160;<a title="Follow Comments via RSS" href="https://www.baeldung.com/java-weekly-642/feed"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/commentsrss20.png"></a>&#160;</div>]]>
</description>
										<content:encoded><![CDATA[<img src="https://www.baeldung.com/wp-content/uploads/2016/10/social-Weekly-Reviews-4.jpg" class="webfeedsFeaturedVisual wp-post-image" alt="" style="float: left; margin-right: 5px;" decoding="async" loading="lazy" srcset="https://www.baeldung.com/wp-content/uploads/2016/10/social-Weekly-Reviews-4.jpg 952w, https://www.baeldung.com/wp-content/uploads/2016/10/social-Weekly-Reviews-4-300x157.jpg 300w, https://www.baeldung.com/wp-content/uploads/2016/10/social-Weekly-Reviews-4-768x402.jpg 768w" sizes="auto, (max-width: 580px) 100vw, 580px" /><h2 style="text-align: left;" id="bd-spring-and-java" data-id="spring-and-java">1.<strong> Spring and Java</strong></h2>
<div class="bd-anchor" id="spring-and-java"></div>
<p><strong><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.infoq.com/articles/spring-team-spring-7-boot-4/">&gt;&gt; The Spring Team on Spring Framework 7 and Spring Boot 4</a></strong> [<span style="color: #993300;">infoq.com</span>]</p>
<p>A walk through what&#8217;s landed in Spring Framework 7 and Spring Boot 4 &#8211; the direction, the rationale, and what it means for the ecosystem. Good overview.</p>
<h4><strong>Also worth reading:</strong></h4>
<ul>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://inside.java/2026/04/13/quality-heads-up/" target="_blank" rel="noopener"><strong>Quality Outreach Heads-up &#8211; JDK 27: Obsolete Translation Resources Removed</strong></a> [<span style="color: #800000;">inside.java</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://blog.jetbrains.com/idea/2026/04/using-spring-data-jdbc-with-kotlin/" target="_blank" rel="noopener"><strong>Using Spring Data JDBC With Kotlin</strong></a> [<span style="color: #800000;">jetbrains.com</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://foojay.io/today/how-i-automated-weekly-twitter-x-posts-with-java-jbang-and-github-actions/" target="_blank" rel="noopener"><strong>How I Automated Weekly Twitter/X Posts With Java, JBang and GitHub Actions</strong></a> [<span style="color: #800000;">foojay.io</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://foojay.io/today/boxlang-ai-deep-dive-part-1-of-7-the-skills-revolution-%f0%9f%8e%93/" target="_blank" rel="noopener"><strong>BoxLang AI Deep Dive — Part 1 of 7: The Skills Revolution</strong></a> [<span style="color: #800000;">foojay.io</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://quarkus.io/blog/reflection-free-jsckson-serializers/" target="_blank" rel="noopener"><strong>Enabling reflection-free Jackson serializers by default</strong></a> [<span style="color: #800000;">quarkus.io</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://spring.io/blog/2026/04/15/spring-ai-session-management" target="_blank" rel="noopener"><strong>Spring AI Agentic Patterns (Part 7): Session API — Event-Sourced Short-Term Memory with Context Compaction</strong></a> [<span style="color: #800000;">spring.io</span>]</li>
</ul>
<h4><strong>Webinars and presentations:</strong></h4>
<ul>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://foojay.io/today/foojay-podcast-93/" target="_blank" rel="noopener"><strong>Foojay Podcast #93: Update Your JDK, Read More Code, and Talk to Your Users: Interviews From VoxxedDays Amsterdam</strong></a> [<span style="color: #800000;">foojay.io</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://inside.java/2026/04/09/podcast-054/" target="_blank" rel="noopener"><strong>Episode 54 “How JDK 26 Improves G1&#8217;s Throughput” [AtA]</strong></a> [<span style="color: #800000;">inside.java</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://spring.io/blog/2026/04/09/a-bootiful-podcast-ana-mark-kropf" target="_blank" rel="noopener"><strong>A Bootiful Podcast: Mark Kropf on AI orchestration</strong></a> [<span style="color: #800000;">spring.io</span>]</li>
</ul>
<h4><strong>Time to upgrade:</strong></h4>
<ul>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://inside.java/2026/04/14/java-vscode-extension-update/" target="_blank" rel="noopener"><strong>Oracle Java Extension for Visual Studio Code Version 25.1.0 Is Now Available</strong></a> [<span style="color: #800000;">inside.java</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://github.com/elastic/elasticsearch/releases/tag/v9.3.3" target="_blank" rel="noopener"><strong>Elasticsearch 9.3.3</strong></a>, <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://github.com/elastic/elasticsearch/releases/tag/v9.2.8" target="_blank" rel="noopener"><strong>9.2.8</strong></a> and <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://github.com/elastic/elasticsearch/releases/tag/v8.19.14" target="_blank" rel="noopener"><strong>8.19.14</strong></a> [<span style="color: #800000;">github.com/elastic</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://github.com/grails/grails-core/releases/tag/v7.1.0" target="_blank" rel="noopener"><strong>Grails 7.1.0</strong></a> [<span style="color: #800000;">github.com/grails</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://github.com/micronaut-projects/micronaut-core/releases/tag/v4.10.21" target="_blank" rel="noopener"><strong>Micronaut Core 4.10.21</strong></a> [<span style="color: #800000;">github.com/micronaut-projects</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://github.com/oracle/helidon/releases/tag/4.4.1" target="_blank" rel="noopener"><strong>Helidon 4.4.1</strong></a> [<span style="color: #800000;">github.com/oracle</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://github.com/apache/camel/releases/tag/camel-4.19.0" target="_blank" rel="noopener"><strong>Camel 4.19.0</strong></a>, <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://github.com/apache/camel/releases/tag/camel-4.18.2" target="_blank" rel="noopener"><strong>4.18.2</strong></a> and <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://github.com/apache/camel/releases/tag/camel-4.14.6" target="_blank" rel="noopener"><strong>4.14.6</strong></a> [<span style="color: #800000;">github.com/apache</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://github.com/payara/Payara/releases/tag/payara-server-7.2026.4" target="_blank" rel="noopener"><strong>Payara Platform Community 7.2026.4</strong></a> [<span style="color: #800000;">github.com/payara</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://github.com/micrometer-metrics/micrometer/releases/tag/v1.16.5" target="_blank" rel="noopener"><strong>Micrometer 1.16.5</strong></a> and <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://github.com/micrometer-metrics/micrometer/releases/tag/v1.15.11" target="_blank" rel="noopener"><strong>1.15.11</strong></a> [<span style="color: #800000;">github.com/micrometer-metrics</span>]</li>
</ul>
<h2 style="text-align: left;" id="bd-technical-amp-musings" data-id="technical-amp-musings">2.<strong> Technical &amp; Musings</strong></h2>
<div class="bd-anchor" id="technical-amp-musings"></div>
<p><strong><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://blog.frankel.ch/agentic-github-workflows/">&gt;&gt; A GitHub agentic workflow</a></strong> [<span style="color: #993300;">frankel.ch</span>]</p>
<p>A hands-on walkthrough of wiring an agentic workflow into GitHub &#8211; using issues and PRs as the coordination surface. Weekend reading.</p>
<h4><strong>Also worth reading:</strong></h4>
<ul>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://lucumr.pocoo.org/2026/4/11/the-center-has-a-bias/" target="_blank" rel="noopener"><strong>The Center Has a Bias</strong></a> [<span style="color: #800000;">lucumr.pocoo.org</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://blog.jbrains.ca/permalink/when-you-can-safely-leave-sprints-behind" target="_blank" rel="noopener"><strong>When You Can Safely Leave Sprints Behind</strong></a> [<span style="color: #800000;">jbrains.ca</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://event-driven.io/en/passive_aggressive_events/" target="_blank" rel="noopener"><strong>Anti-patterns in event modelling &#8211; Passive-Aggressive Events</strong></a> [<span style="color: #800000;">event-driven.io</span>]</li>
<li><strong>&gt;&gt;</strong> <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://netflixtechblog.com/evaluating-netflix-show-synopses-with-llm-as-a-judge-6269251e6f28" target="_blank" rel="noopener"><strong>Evaluating Netflix Show Synopses with LLM-as-a-Judge</strong></a> [<span style="color: #800000;">netflixtechblog.com</span>]</li>
</ul>
<h2 style="text-align: left;" id="bd-pick-of-the-week" data-id="pick-of-the-week">3.<strong> Pick of the Week</strong></h2>
<div class="bd-anchor" id="pick-of-the-week"></div>
<p><strong><a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://sive.rs/balance">&gt;&gt; How to do what you love and make good money</a></strong> [<span style="color: #993300;">sive.rs</span>]</p>The post <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-weekly-642">Java Weekly, Issue 642</a> first appeared on <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com">Baeldung</a>.<Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/953941595/0/baeldung">
<div style="clear:both;padding-top:0.2em;"><a title="Like on Facebook" href="https://feeds.feedblitz.com/_/28/953941595/baeldung"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Pin it!" href="https://feeds.feedblitz.com/_/29/953941595/baeldung,https%3a%2f%2fwww.baeldung.com%2fwp-content%2fuploads%2f2016%2f10%2fsocial-Weekly-Reviews-4.jpg"><img height="20" src="https://assets.feedblitz.com/i/pinterest20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Post to X.com" href="https://feeds.feedblitz.com/_/24/953941595/baeldung"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by email" href="https://feeds.feedblitz.com/_/19/953941595/baeldung"><img height="20" src="https://assets.feedblitz.com/i/email20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by RSS" href="https://feeds.feedblitz.com/_/20/953941595/baeldung"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a rel="NOFOLLOW" title="View Comments" href="https://www.baeldung.com/java-weekly-642#respond"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/comments20.png"></a>&#160;<a title="Follow Comments via RSS" href="https://www.baeldung.com/java-weekly-642/feed"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/commentsrss20.png"></a>&#160;</div>]]>
</content:encoded>
					
					<wfw:commentRss>https://feeds.feedblitz.com/~/953941595/0/baeldung~Java-Weekly-Issue/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<webfeeds:featuredImage>https://www.baeldung.com/wp-content/uploads/2016/10/social-Weekly-Reviews-4-150x150.jpg</webfeeds:featuredImage></item>
<item>
<feedburner:origLink>https://www.baeldung.com/java-regex-resolving-patternsyntaxexception</feedburner:origLink>
		<title>Resolving PatternSyntaxException: Unclosed character class</title>
		<link>https://feeds.feedblitz.com/~/953868626/0/baeldung~Resolving-PatternSyntaxException-Unclosed-character-class</link>
					<comments>https://feeds.feedblitz.com/~/953868626/0/baeldung~Resolving-PatternSyntaxException-Unclosed-character-class#respond</comments>
		
		<dc:creator><![CDATA[Neetika Khandelwal]]></dc:creator>
		<pubDate>Thu, 16 Apr 2026 03:30:58 +0000</pubDate>
				<category><![CDATA[Java String]]></category>
		<category><![CDATA[Exception]]></category>
		<category><![CDATA[Regex]]></category>
		<guid isPermaLink="false">https://www.baeldung.com/?p=203471</guid>
					<description><![CDATA[<img src="https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-15-1024x536.jpg" class="webfeedsFeaturedVisual wp-post-image" alt="" style="max-width:100% !important;height:auto !important;float: left; margin-right: 5px;" loading="lazy" /><p>Learn about the PatternSyntaxException: Unclosed character class which is a common yet avoidable issue in Java regular expressions</p>
The post <a rel="NOFOLLOW" href="https://feeds.feedblitz.com/~/953868626/0/baeldung~Resolving-PatternSyntaxException-Unclosed-character-class">Resolving PatternSyntaxException: Unclosed character class</a> first appeared on <a rel="NOFOLLOW" href="https://www.baeldung.com">Baeldung</a>.<div style="clear:both;padding-top:0.2em;"><a title="Like on Facebook" href="https://feeds.feedblitz.com/_/28/953868626/baeldung"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Pin it!" href="https://feeds.feedblitz.com/_/29/953868626/baeldung,https%3a%2f%2fwww.baeldung.com%2fwp-content%2fuploads%2f2024%2f07%2fJava-Featured-15-1024x536.jpg"><img height="20" src="https://assets.feedblitz.com/i/pinterest20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Post to X.com" href="https://feeds.feedblitz.com/_/24/953868626/baeldung"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by email" href="https://feeds.feedblitz.com/_/19/953868626/baeldung"><img height="20" src="https://assets.feedblitz.com/i/email20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by RSS" href="https://feeds.feedblitz.com/_/20/953868626/baeldung"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a rel="NOFOLLOW" title="View Comments" href="https://www.baeldung.com/java-regex-resolving-patternsyntaxexception#respond"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/comments20.png"></a>&#160;<a title="Follow Comments via RSS" href="https://www.baeldung.com/java-regex-resolving-patternsyntaxexception/feed"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/commentsrss20.png"></a>&#160;</div>]]>
</description>
										<content:encoded><![CDATA[<img src="https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-15-1024x536.jpg" class="webfeedsFeaturedVisual wp-post-image" alt="" style="float: left; margin-right: 5px;" decoding="async" loading="lazy" srcset="https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-15-1024x536.jpg 1024w, https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-15-300x157.jpg 300w, https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-15-768x402.jpg 768w, https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-15-100x52.jpg 100w, https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-15.jpg 1200w" sizes="auto, (max-width: 580px) 100vw, 580px" /><h2 id="bd-overview" data-id="overview">1. Overview</h2>
<div class="bd-anchor" id="overview"></div>
<p>When we work with regular expressions in Java, even a small syntax mistake can break our application at runtime. One of the most common errors we encounter is:</p>
<pre><code class="language-java">java.util.regex.PatternSyntaxException: Unclosed character class</code></pre>
<p>In this tutorial, we&#8217;ll explore why this happens, how to reproduce it, and how to fix it. We also cover a real-world issue involving <em>split()</em> that often triggers this exception.</p>
<h2 id="bd-understanding-character-classes" data-id="understanding-character-classes">2. Understanding Character Classes</h2>
<div class="bd-anchor" id="understanding-character-classes"></div>
<p><strong>A character class in <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/regular-expressions-java">regex</a> allows us to match</strong> <strong data-start="704" data-end="742">any one character from a given set</strong>. This is one of the most commonly used regex constructs in Java.
<br>
Let us first look at a simple example of a character class:</p>
<pre><code class="language-java">"[abc]"</code></pre>
<p>In this pattern, the regex engine matches either <em>a</em>, <em>b</em>, or <em>c</em>. <strong>We should always remember that a character class starts with [ and must end with ]. </strong>We can also define ranges when working with larger sets of characters:</p>
<pre><code class="language-java">"[a-z]"</code></pre>
<p>This pattern matches any lowercase English letter from <em>a</em> to <em>z</em>. <strong>If we forget to close the bracket, Java will throw a runtime exception.</strong></p>
<h2 id="bd-reproducing-the-exception" data-id="reproducing-the-exception">3. Reproducing the Exception</h2>
<div class="bd-anchor" id="reproducing-the-exception"></div>
<p>To better understand the problem, let us intentionally write an invalid regex pattern. This helps us see exactly how Java reacts:</p>
<pre><code class="language-java">public class RegexExample {
    public static void main(String[] args) {
        Pattern.compile("[a-z");
    }
}</code></pre>
<p>In the above example, we try to compile a regex that starts a character class but never closes it. When we run this code, Java throws the following exception:</p>
<pre><code class="language-java">java.util.regex.PatternSyntaxException: Unclosed character class near index 4
[a-z
    ^</code></pre>
<p>This clearly indicates that the regex parser expected a closing ] but did not find one.</p>
<h2 id="bd-fixing-the-exception" data-id="fixing-the-exception">4. Fixing the Exception</h2>
<div class="bd-anchor" id="fixing-the-exception"></div>
<p>Now that we understand the problem, fixing it becomes straightforward. We simply need to close the character class properly:</p>
<pre><code class="language-java">Pattern.compile("[a-z]");</code></pre>
<p>After making this change, the pattern compiles successfully without any errors. <strong data-start="2266" data-end="2357">We should always verify that every opening bracket has a corresponding closing bracket.</strong></p>
<h2 id="bd-common-causes-of-this-exception" data-id="common-causes-of-this-exception">5. Common Causes of This Exception</h2>
<div class="bd-anchor" id="common-causes-of-this-exception"></div>
<p>Let&#8217;s have a look at some of the common causes of <em>PatternSyntaxException</em>.</p>
<h3 data-start="2406" data-end="2440" id="bd-1-missing-closing-bracket" data-id="1-missing-closing-bracket">5.1. Missing Closing Bracket</h3>
<div class="bd-anchor" id="1-missing-closing-bracket"></div>
<p>One of the most frequent mistakes is forgetting to close the character class:</p>
<pre><code class="language-java">Pattern.compile("[0-9");</code></pre>
<p>This pattern is incomplete and results in a runtime exception. We can fix it by adding the missing closing bracket:</p>
<pre><code class="language-java">Pattern.compile("[0-9]");</code></pre>
<p><strong>Even a small omission like this can break the entire regex.</strong></p>
<h3 data-start="2791" data-end="2827" id="bd-2-incorrect-nested-patterns" data-id="2-incorrect-nested-patterns">5.2. Incorrect Nested Patterns</h3>
<div class="bd-anchor" id="2-incorrect-nested-patterns"></div>
<p>Sometimes, while writing a complex regex, we accidentally introduce extra brackets:</p>
<pre><code class="language-java">Pattern.compile("[a-zA-Z[0-9]");</code></pre>
<p>In this pattern, we have an extra [ inside the character class.<strong> Character classes do not support nesting using [ like this, so the regex becomes invalid</strong>. As a result, Java throws a <em>PatternSyntaxException</em>.</p>
<p>To fix this, we should remove the unnecessary bracket and define the character set correctly:</p>
<pre><code class="language-java">Pattern.compile("[a-zA-Z0-9]");</code></pre>
<p>Now the pattern is valid and matches any alphanumeric character. <strong data-start="983" data-end="1081">Instead of nesting, we should combine all required characters within a single character class.</strong></p>
<h2 id="bd-issue-with-split" data-id="issue-with-split">6. Issue with <em data-start="3673" data-end="3682">split()</em></h2>
<div class="bd-anchor" id="issue-with-split"></div>
<p>Let us now look at a practical example that often causes confusion in real projects. Before jumping into the issue, we first define a sample 2D array.</p>
<pre><code class="language-java">String[][] array2d = {
    {"a", "b"},
    {"c", "d"}
};</code></pre>
<p>In many cases, we convert this array into a string using <em data-start="656" data-end="679">Arrays.deepToString()</em> for quick inspection or processing:</p>
<pre><code class="language-java">String str = Arrays.deepToString(array2d);
System.out.println(str);</code></pre>
<p>When we run this, the output looks like:</p>
<pre><code class="language-java">[[a, b], [c, d]]</code></pre>
<p><strong data-start="894" data-end="953">Notice that the output contains nested square brackets.</strong> This is important for understanding the issue. Now, let us attempt to split this string into individual rows. At first glance, the following code looks correct:</p>
<pre><code class="language-java">String[][] split = new String[1][rows];
split[0] = str.split("], [");</code></pre>
<p>However, when we run this code, we encounter a runtime exception:</p>
<pre><code class="language-java">java.util.regex.PatternSyntaxException: Unclosed character class</code></pre>
<p>This happens because <em data-start="1397" data-end="1406">split()</em> expects a <strong data-start="1417" data-end="1426">regex</strong>, not a plain string. The pattern: &#8220;], [&#8221; is interpreted incorrectly, since [ and ] are special characters in regex. <strong data-start="1578" data-end="1683">As a result, the regex engine treats [ as the start of a character class, leading to the exception.</strong>
<br>
To resolve this issue, we need to escape the square brackets so they are treated as literal characters:</p>
<pre><code class="language-java">split[0] = str.split("\\], \\[");</code></pre>
<p>With this change, the regex becomes valid, and the code works as expected. <strong data-start="4534" data-end="4609">Proper escaping ensures that special characters do not break our regex. </strong>Although the fix works, we can further improve the solution for cleaner output. The result of <em data-start="4745" data-end="4768">Arrays.deepToString()</em> contains outer brackets that we may want to remove:</p>
<pre><code class="language-java">String str = Arrays.deepToString(array2d);
str = str.substring(1, str.length() - 1);
String[] result = str.split("\\], \\[");</code></pre>
<p>By trimming the outer brackets, we get a cleaner split result. <strong data-start="5027" data-end="5102">This makes the output easier to process and avoids unwanted characters.</strong></p>
<h2 id="bd-conclusion" data-id="conclusion">7. Conclusion</h2>
<div class="bd-anchor" id="conclusion"></div>
<p>In this article, we saw that the <em>PatternSyntaxException: Unclosed character class</em> is a common yet avoidable issue in Java. It usually occurs due to missing brackets or incorrect handling of special characters like [ and ]. By carefully writing regex patterns, properly escaping characters in methods like <em>split()</em>, and validating inputs, we can build more reliable applications. A small attention to detail in regex can prevent major runtime issues.</p>
<p>As always, the code presented in this article is available <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://github.com/eugenp/tutorials/tree/master/core-java-modules/core-java-regex-4">over on GitHub</a>.</p>The post <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com/java-regex-resolving-patternsyntaxexception">Resolving PatternSyntaxException: Unclosed character class</a> first appeared on <a href="http://feeds.feedblitz.com/~/t/0/0/baeldung/~https://www.baeldung.com">Baeldung</a>.<Img align="left" border="0" height="1" width="1" alt="" style="border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;" hspace="0" src="https://feeds.feedblitz.com/~/i/953868626/0/baeldung">
<div style="clear:both;padding-top:0.2em;"><a title="Like on Facebook" href="https://feeds.feedblitz.com/_/28/953868626/baeldung"><img height="20" src="https://assets.feedblitz.com/i/fblike20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Pin it!" href="https://feeds.feedblitz.com/_/29/953868626/baeldung,https%3a%2f%2fwww.baeldung.com%2fwp-content%2fuploads%2f2024%2f07%2fJava-Featured-15-1024x536.jpg"><img height="20" src="https://assets.feedblitz.com/i/pinterest20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Post to X.com" href="https://feeds.feedblitz.com/_/24/953868626/baeldung"><img height="20" src="https://assets.feedblitz.com/i/x.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by email" href="https://feeds.feedblitz.com/_/19/953868626/baeldung"><img height="20" src="https://assets.feedblitz.com/i/email20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a title="Subscribe by RSS" href="https://feeds.feedblitz.com/_/20/953868626/baeldung"><img height="20" src="https://assets.feedblitz.com/i/rss20.png" style="border:0;margin:0;padding:0;"></a>&#160;<a rel="NOFOLLOW" title="View Comments" href="https://www.baeldung.com/java-regex-resolving-patternsyntaxexception#respond"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/comments20.png"></a>&#160;<a title="Follow Comments via RSS" href="https://www.baeldung.com/java-regex-resolving-patternsyntaxexception/feed"><img height="20" style="border:0;margin:0;padding:0;" src="https://assets.feedblitz.com/i/commentsrss20.png"></a>&#160;</div>]]>
</content:encoded>
					
					<wfw:commentRss>https://feeds.feedblitz.com/~/953868626/0/baeldung~Resolving-PatternSyntaxException-Unclosed-character-class/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<webfeeds:featuredImage>https://www.baeldung.com/wp-content/uploads/2024/07/Java-Featured-15-150x150.jpg</webfeeds:featuredImage></item>
</channel></rss>

