SlideShare a Scribd company logo
Java and AI with
LangChain4j
Code the future with AI
Ed Burns @edburns
Principal Architect
PENDING download link
Ed Burns professional biography
 Client
 NCSA Mosaic (1994)
 SGI Cosmo Web Authoring
 Sun Netscape 6 OJI
 Server
 J2EE JSF (2002)
 Oracle Java EE
 Servlet, JSF, Bean Validation, etc.
 Cloud
 Java Champion
 Microsoft Azure Cloud (2019)
 Jakarta EE 11 committer and release coordinator
 Books
Change in content from posted agenda
 Still 100% Java and AI with LangChain4j.
 Removed content:
 After a brief look at the landscape.
 How you use it to perform the most popular AI usage pattern:
Retrieval Augmented Generation (RAG).
 Added content:
 langchain4j-microprofile-jakarta.
 If you want the RAG content, I recommend Easy RAG with
LangChain4J and Docker by Julien Dubois.
JUG Tour Around JavaLand 2025
Breaking Jakarta EE news
 Jakarta EE 11 Web Profile started release review ballot Monday!
 https://github.com/jakartaee/specifications/pull/802
 https://deploy-preview-802--jakartaee-
specifications.netlify.app/specifications/webprofile/11/
 Many EE 12 component specifications in Plan Review stage.
 MicroProfile is discussing whether and how to host MicroProfile in
Jakarta EE.
 The need for a unified Config solution for EE 12.
 Coincidentally timed soon after Evolving our middleware strategy blog post
from Red Hat.
AI related career advice
Everyone I know admits: AI is moving faster than
anything that has come before
https://aka.ms/DeveloperCareerMasterplan/slides https://aka.ms/RockStarProgrammerSecrets
Scott Hanselman: Let’s all just
chill
From a trust perspective
 Very important to keep the
“intelligence” in AI in
perspective.
 LLMs cannot answer simple
questions such as “Which
episode of Gilligan’s Island was
about mind reading?”
 The question that no LLM can answer and
why it is important
https://www.mindprison.cc/p/the-question-that-no-llm-can-answer
Java meets AI
Content from Emmanuel Hugonnet http://www.ehsavoie.com/
Jakarta EE meets AI
smallrye-llm
langchain4j-
microprofile
-jakarta
Microprofile config
Microprofile Fault Tolerance Microprofile
OpenTelemetry
CDI
Content from Emmanuel Hugonnet http://www.ehsavoie.com/
Components of LangChain4J
Content from Emmanuel Hugonnet http://www.ehsavoie.com/
Quick look at LangChain4j examples
 https://github.com/langchain4j/langchain4j-examples
Components of SmallRye LLM/LangChain4J Jakarta
1. AI Service Interface Processing:
o Detects interfaces annotated with @RegisterAIService
o Generates proxy implementations using LangChain4J
o Makes them available as CDI beans
2. Plugin Bean Creation:
o Reads configuration from properties with smallrye.llm.plugin.* prefix
o Creates beans for LangChain4J components (models, embedding stores)
o Makes these components available for injection
3. MicroProfile Config Integration:
o Translates properties to LangChain4J configuration
o Handles environment variable substitution (e.g., ${azure.openai.api.key})
4. Fault Tolerance:
o Provides integration with MicroProfile Fault Tolerance
o Adds resilience to AI service calls
5. Telemetry:
o Provides observability for AI service calls
o Integrates with OpenTelemetry
Some Code
CDI Injection
Injection.java
@Inject
@Named(value = "ollama")
ChatLanguageModel chatModel;
@Inject
@Named(value = "embedding-store-retriever")
ContentRetriever retriever;
Content from Emmanuel Hugonnet http://www.ehsavoie.com/
AI Service
SimpleAIService.java
@RegisterAIService(chatLanguageModelName = "ollama", tools =
{org.wildfly.ai.websocket.Weather.class,org.wildfly.ai.websocket.Cal
culator.class}, scope = SessionScoped.class)
public interface SimpleAIService {
@SystemMessage("""
You are an AI named Bob answering general question.
Your response must be polite, use the same language
as the question, and be relevant to the question.""")
String chat(@UserMessage String question);
}
Content from Emmanuel Hugonnet http://www.ehsavoie.com/
Another approach, with MCP
But what is MCP?
But what is MCP?
https://modelcontextprotocol.io/
But what is MCP?
 https://github.com/modelcontextprotocol/servers
Demo
Content from Emmanuel Hugonnet http://www.ehsavoie.com/
MCP
Server
MCP tools workflow
MCP
Server
Web
Application
LLM
MCP
Server
1
2 3
4
MCP
Server
5
6
Content from Emmanuel Hugonnet http://www.ehsavoie.com/
MCP
Server
Database
Filesystem
Message queue
JavaFX
AI Service with MCP Tools
SimpleAIService.java
@RegisterAIService(streamingChatLanguageModelName= "streaming-
ollama", toolProviderName = "mcp")
public interface ChatAiService {
@SystemMessage("""
You are an AI named Bob answering general question.
Your response must be polite, use the same language
as the question, and be relevant to the question.""")
TokenStream streamingChat(@UserMessage String question);
}
Content from Emmanuel Hugonnet http://www.ehsavoie.com/
Demo
Content from Emmanuel Hugonnet http://www.ehsavoie.com/
Conclusion
Content from Emmanuel Hugonnet http://www.ehsavoie.com/
What we saw
External configuration instead of code
CDI Injection
AI Service support
Cross-vendors: Micronaute, OpenLiberty, Quarkus, WildFly
Enterprise ready : OpenTelemetry / Fault Tolerance / MCP
Makes LangChain4J even easier to use !
Content from Emmanuel Hugonnet http://www.ehsavoie.com/
Resources
• LangChain4J:
o https://docs.langchain4j.dev/
• Model Context Protocol:
o https://spec.modelcontextprotocol.io/
• smallrye-llm: a cross vendor LangChain4J -CDI integration library
o https://github.com/smallrye/smallrye-llm
• WildFly AI Feature Pack:
o https://github.com/wildfly-extras/wildfly-ai-feature-pack
• WildFly MCP: to interact with WildFly servers through MCP
o https://github.com/wildfly-extras/wildfly-mcp
• Admin your WildFly with LLM and MCP
o https://www.youtube.com/watch?v=wg1hAdOoe2w
• Making WildFly Glow with Intelligence:
o https://www.wildfly.org/news/2025/02/10/Glowing-with-AI/
• Playing with Generative AI with WildFly:
o https://www.wildfly.org/news/2024/11/04/WildFly-playing-with-generative-ai/
Thank you
Ed Burns
@edburns on most of the things
• Please fill out this survey
• 5 winners will be chosen to win a $100 digital gift card
• https://aka.ms/edburns/survey2025
1.What is your key decision making process when it comes to app
modernization?
2.What’s your key challenge when modernizing your Java workload?
3.Are you a Java only shop or multiple language shop?
4.What is the tech stack/framework for your Java apps?
5.When migrating, what is your primary destination on cloud? What
platform are you choosing? VM? PaaS? Containers? Why?
6.How did you or your team make the above decisions?

More Related Content

PDF
Java and AI with LangChain4j: Jakarta EE gets AI
PDF
Java and AI with LangChain4j: Jakarta EE and AI
PDF
Adobe Photoshop 2025 Free crack Download
PDF
Java and AI with LangChain4j: Integrating Jakarta EE and LLMs
PDF
Building and deploying AI agents in Java
PDF
Building AI agents with Java and LangChain4j
PDF
AI in Java - MCP in Action, Langchain4J-CDI, SmallRye-LLM, Spring AI
PDF
Jakarta meets AI (JakartaEE One Livestream presentation)
Java and AI with LangChain4j: Jakarta EE gets AI
Java and AI with LangChain4j: Jakarta EE and AI
Adobe Photoshop 2025 Free crack Download
Java and AI with LangChain4j: Integrating Jakarta EE and LLMs
Building and deploying AI agents in Java
Building AI agents with Java and LangChain4j
AI in Java - MCP in Action, Langchain4J-CDI, SmallRye-LLM, Spring AI
Jakarta meets AI (JakartaEE One Livestream presentation)

Similar to Java and AI with LangChain4j: Jakarta EE and SmallRye LLM (20)

PDF
When GenAI meets with Java with Quarkus and langchain4j
PDF
Java Forum Nord - Hannover - The Trinity in GenAI - Spring AI, LangChain4J a...
PDF
Java Developers - What Lies Ahead in the AI era
ODP
JUDCON India 2014 Java EE 7 talk
PDF
What need to be mastered as AI-Powered Java Developers
PPTX
Enterprise Meets LLM: AI-Powered Apps with Spring AI
PDF
Reactive robotics io_t_2017
PPT
Open Programmable Architecture for Java-enabled Network Devices
PPT
Open programmable architecture for java enabled network devices
PDF
Java one2013
PDF
Microservices Architecture For Conversational Intelligence Platform
PDF
Reactive Java Robotics & IoT with Spring Reactor
PPT
Developing Java Web Applications
PDF
Java & JavaScipt Reactive Robotics and IoT 2016 @ jProfessionals
PDF
LLM with Java.pdf
PDF
Building Asynchronous Applications
PPTX
Architectures, Frameworks and Infrastructure
PPTX
Be faster then rabbits
PPTX
Langchainfdgdfsggfdgfsdgsdgdfsgfdgfdgfdgfd
KEY
Google App Engine Java, Groovy and Gaelyk
When GenAI meets with Java with Quarkus and langchain4j
Java Forum Nord - Hannover - The Trinity in GenAI - Spring AI, LangChain4J a...
Java Developers - What Lies Ahead in the AI era
JUDCON India 2014 Java EE 7 talk
What need to be mastered as AI-Powered Java Developers
Enterprise Meets LLM: AI-Powered Apps with Spring AI
Reactive robotics io_t_2017
Open Programmable Architecture for Java-enabled Network Devices
Open programmable architecture for java enabled network devices
Java one2013
Microservices Architecture For Conversational Intelligence Platform
Reactive Java Robotics & IoT with Spring Reactor
Developing Java Web Applications
Java & JavaScipt Reactive Robotics and IoT 2016 @ jProfessionals
LLM with Java.pdf
Building Asynchronous Applications
Architectures, Frameworks and Infrastructure
Be faster then rabbits
Langchainfdgdfsggfdgfsdgsdgdfsgfdgfdgfdgfd
Google App Engine Java, Groovy and Gaelyk
Ad

More from Edward Burns (20)

PDF
Jakarta EE 11: What's New and Why You Should Care
PDF
20250403-trusted-ai-favorite-ide-javaland.pdf
PDF
A survey of cloud readiness for Jakarta EE 11
PDF
How to get trusted AI in your favorite IDE
PDF
How to get trusted AI in your favorite IDE
PDF
How to get trusted AI in your favorite IDE
PDF
How to get trusted AI in your favorite IDE
PPTX
2024-09-10 Jacksonville JUG Java on Azure with AI
PPTX
Deliver AI infused app innovation with Open Liberty on AKS
PPTX
DevTalks Romania: Prepare for Jakarta EE 11
PDF
Developer Career Masterplan
PPTX
Jakarta EE 11 Status Update​
PDF
Sponsored Session: Please touch that dial!
PDF
How modernizing enterprise applications gives you a competitive advantage
PDF
Wie Azure Jakarta EE Nutzt
PDF
Practical lessons from customers performing digital transformation with Azure
PDF
wls-azure-devnexus-2022.pdf
PDF
Jakarta EE und Microprofile sind bei Azure zu Hause
PDF
Java on Your Terms with Azure
PDF
Wars I’ve Seen From Java EE to Spring and more, Azure has you covered
Jakarta EE 11: What's New and Why You Should Care
20250403-trusted-ai-favorite-ide-javaland.pdf
A survey of cloud readiness for Jakarta EE 11
How to get trusted AI in your favorite IDE
How to get trusted AI in your favorite IDE
How to get trusted AI in your favorite IDE
How to get trusted AI in your favorite IDE
2024-09-10 Jacksonville JUG Java on Azure with AI
Deliver AI infused app innovation with Open Liberty on AKS
DevTalks Romania: Prepare for Jakarta EE 11
Developer Career Masterplan
Jakarta EE 11 Status Update​
Sponsored Session: Please touch that dial!
How modernizing enterprise applications gives you a competitive advantage
Wie Azure Jakarta EE Nutzt
Practical lessons from customers performing digital transformation with Azure
wls-azure-devnexus-2022.pdf
Jakarta EE und Microprofile sind bei Azure zu Hause
Java on Your Terms with Azure
Wars I’ve Seen From Java EE to Spring and more, Azure has you covered
Ad

Recently uploaded (20)

PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Cost to Outsource Software Development in 2025
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
top salesforce developer skills in 2025.pdf
PDF
Designing Intelligence for the Shop Floor.pdf
PDF
Digital Strategies for Manufacturing Companies
PDF
Understanding Forklifts - TECH EHS Solution
PPTX
history of c programming in notes for students .pptx
PDF
medical staffing services at VALiNTRY
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PPTX
Computer Software and OS of computer science of grade 11.pptx
PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Cost to Outsource Software Development in 2025
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
top salesforce developer skills in 2025.pdf
Designing Intelligence for the Shop Floor.pdf
Digital Strategies for Manufacturing Companies
Understanding Forklifts - TECH EHS Solution
history of c programming in notes for students .pptx
medical staffing services at VALiNTRY
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
Computer Software and OS of computer science of grade 11.pptx
CHAPTER 2 - PM Management and IT Context
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
How to Choose the Right IT Partner for Your Business in Malaysia
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Softaken Excel to vCard Converter Software.pdf
Operating system designcfffgfgggggggvggggggggg
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx

Java and AI with LangChain4j: Jakarta EE and SmallRye LLM

  • 1. Java and AI with LangChain4j Code the future with AI Ed Burns @edburns Principal Architect PENDING download link
  • 2. Ed Burns professional biography  Client  NCSA Mosaic (1994)  SGI Cosmo Web Authoring  Sun Netscape 6 OJI  Server  J2EE JSF (2002)  Oracle Java EE  Servlet, JSF, Bean Validation, etc.  Cloud  Java Champion  Microsoft Azure Cloud (2019)  Jakarta EE 11 committer and release coordinator  Books
  • 3. Change in content from posted agenda  Still 100% Java and AI with LangChain4j.  Removed content:  After a brief look at the landscape.  How you use it to perform the most popular AI usage pattern: Retrieval Augmented Generation (RAG).  Added content:  langchain4j-microprofile-jakarta.  If you want the RAG content, I recommend Easy RAG with LangChain4J and Docker by Julien Dubois.
  • 4. JUG Tour Around JavaLand 2025
  • 5. Breaking Jakarta EE news  Jakarta EE 11 Web Profile started release review ballot Monday!  https://github.com/jakartaee/specifications/pull/802  https://deploy-preview-802--jakartaee- specifications.netlify.app/specifications/webprofile/11/  Many EE 12 component specifications in Plan Review stage.  MicroProfile is discussing whether and how to host MicroProfile in Jakarta EE.  The need for a unified Config solution for EE 12.  Coincidentally timed soon after Evolving our middleware strategy blog post from Red Hat.
  • 7. Everyone I know admits: AI is moving faster than anything that has come before https://aka.ms/DeveloperCareerMasterplan/slides https://aka.ms/RockStarProgrammerSecrets
  • 8. Scott Hanselman: Let’s all just chill From a trust perspective  Very important to keep the “intelligence” in AI in perspective.  LLMs cannot answer simple questions such as “Which episode of Gilligan’s Island was about mind reading?”  The question that no LLM can answer and why it is important https://www.mindprison.cc/p/the-question-that-no-llm-can-answer
  • 9. Java meets AI Content from Emmanuel Hugonnet http://www.ehsavoie.com/
  • 10. Jakarta EE meets AI smallrye-llm langchain4j- microprofile -jakarta Microprofile config Microprofile Fault Tolerance Microprofile OpenTelemetry CDI Content from Emmanuel Hugonnet http://www.ehsavoie.com/
  • 11. Components of LangChain4J Content from Emmanuel Hugonnet http://www.ehsavoie.com/
  • 12. Quick look at LangChain4j examples  https://github.com/langchain4j/langchain4j-examples
  • 13. Components of SmallRye LLM/LangChain4J Jakarta 1. AI Service Interface Processing: o Detects interfaces annotated with @RegisterAIService o Generates proxy implementations using LangChain4J o Makes them available as CDI beans 2. Plugin Bean Creation: o Reads configuration from properties with smallrye.llm.plugin.* prefix o Creates beans for LangChain4J components (models, embedding stores) o Makes these components available for injection 3. MicroProfile Config Integration: o Translates properties to LangChain4J configuration o Handles environment variable substitution (e.g., ${azure.openai.api.key}) 4. Fault Tolerance: o Provides integration with MicroProfile Fault Tolerance o Adds resilience to AI service calls 5. Telemetry: o Provides observability for AI service calls o Integrates with OpenTelemetry
  • 15. CDI Injection Injection.java @Inject @Named(value = "ollama") ChatLanguageModel chatModel; @Inject @Named(value = "embedding-store-retriever") ContentRetriever retriever; Content from Emmanuel Hugonnet http://www.ehsavoie.com/
  • 16. AI Service SimpleAIService.java @RegisterAIService(chatLanguageModelName = "ollama", tools = {org.wildfly.ai.websocket.Weather.class,org.wildfly.ai.websocket.Cal culator.class}, scope = SessionScoped.class) public interface SimpleAIService { @SystemMessage(""" You are an AI named Bob answering general question. Your response must be polite, use the same language as the question, and be relevant to the question.""") String chat(@UserMessage String question); } Content from Emmanuel Hugonnet http://www.ehsavoie.com/
  • 18. But what is MCP?
  • 19. But what is MCP? https://modelcontextprotocol.io/
  • 20. But what is MCP?  https://github.com/modelcontextprotocol/servers
  • 21. Demo Content from Emmanuel Hugonnet http://www.ehsavoie.com/
  • 22. MCP Server MCP tools workflow MCP Server Web Application LLM MCP Server 1 2 3 4 MCP Server 5 6 Content from Emmanuel Hugonnet http://www.ehsavoie.com/ MCP Server Database Filesystem Message queue JavaFX
  • 23. AI Service with MCP Tools SimpleAIService.java @RegisterAIService(streamingChatLanguageModelName= "streaming- ollama", toolProviderName = "mcp") public interface ChatAiService { @SystemMessage(""" You are an AI named Bob answering general question. Your response must be polite, use the same language as the question, and be relevant to the question.""") TokenStream streamingChat(@UserMessage String question); } Content from Emmanuel Hugonnet http://www.ehsavoie.com/
  • 24. Demo Content from Emmanuel Hugonnet http://www.ehsavoie.com/
  • 25. Conclusion Content from Emmanuel Hugonnet http://www.ehsavoie.com/
  • 26. What we saw External configuration instead of code CDI Injection AI Service support Cross-vendors: Micronaute, OpenLiberty, Quarkus, WildFly Enterprise ready : OpenTelemetry / Fault Tolerance / MCP Makes LangChain4J even easier to use ! Content from Emmanuel Hugonnet http://www.ehsavoie.com/
  • 27. Resources • LangChain4J: o https://docs.langchain4j.dev/ • Model Context Protocol: o https://spec.modelcontextprotocol.io/ • smallrye-llm: a cross vendor LangChain4J -CDI integration library o https://github.com/smallrye/smallrye-llm • WildFly AI Feature Pack: o https://github.com/wildfly-extras/wildfly-ai-feature-pack • WildFly MCP: to interact with WildFly servers through MCP o https://github.com/wildfly-extras/wildfly-mcp • Admin your WildFly with LLM and MCP o https://www.youtube.com/watch?v=wg1hAdOoe2w • Making WildFly Glow with Intelligence: o https://www.wildfly.org/news/2025/02/10/Glowing-with-AI/ • Playing with Generative AI with WildFly: o https://www.wildfly.org/news/2024/11/04/WildFly-playing-with-generative-ai/
  • 28. Thank you Ed Burns @edburns on most of the things • Please fill out this survey • 5 winners will be chosen to win a $100 digital gift card • https://aka.ms/edburns/survey2025
  • 29. 1.What is your key decision making process when it comes to app modernization? 2.What’s your key challenge when modernizing your Java workload? 3.Are you a Java only shop or multiple language shop? 4.What is the tech stack/framework for your Java apps? 5.When migrating, what is your primary destination on cloud? What platform are you choosing? VM? PaaS? Containers? Why? 6.How did you or your team make the above decisions?