Shaaf's blog

A technical blog about Java, Kubernetes and things that matter

Java+LLMs: A hands-on guide to building LLM Apps in Java

I had the pleasure to present about building Java applications using LLMs together with Bazlur at GeeCon 2025. The weather was amazing and Krakow is a beautiful historical city.

Key Topics Covered

Here are the key topics from the video with direct links to those sections:

  • LangChain4j Basics: An introduction to the framework, demonstrating how it abstracts communication with various LLMs like OpenAI and Gemini using builder patterns.
  • Prompt Engineering: The speakers explain the difference between System Prompts (defining the AI’s behavior/personality) and User Prompts (the specific query).
  • AI Services & Streaming: A look at how to create high-level interfaces for AI interactions, including streaming responses for real-time chat experiences.
  • Memory Management: How to provide LLMs with context from previous conversations using providers like MessageWindowChatMemory and storing history in databases.
  • Tools (Function Calling): A deep dive into how LLMs can trigger Java methods to perform specific tasks, such as fetching web content or compiling Java code.
  • Jakarta EE Project Generator: A demonstration of using an LLM tool to generate a complete Jakarta EE project structure via a chat interface.
  • Retrieval-Augmented Generation (RAG): Using PGVector and embedding models to store and retrieve private data efficiently.
  • Chunking and Tokenization: The importance of segmenting data so the AI receives the right context without exceeding token limits.
  • Model Context Protocol (MCP): An introduction to the standard for connecting AI models to external data sources and tools.
  • Q&A Session: Discussions on prompt injection, guardrails, and testing non-deterministic AI outputs.

Next up we are both busy building a workshop about Langchain4j and its integration with Spring. If you are interested in learning more join us at JNation.pt. Bring your laptop the session will be 180 minutes and lots to code about ;)


A Keycloak example - building my first MCP server Tools with Quarkus

Recently I wrote an article about “Adoption of the Model Context Protocol Within the Java Ecosystem”. Now it was also time to start experimenting with writing an MCP Server myself (well maybe not the first time). Certainly I don’t want to be left out of all the cool things being demonstrated by the community. The goal for me is to learn, and creating perhaps a more practical example. In this post I am going to choose Keycloak, and write an experimental MCP server implementation for keycloak. The post is also to spark interest around this topic. Will it be useful to have an MCP server for Keycloak?


TechTalk - Java + LLMs: A hands-on guide to building LLM Apps in Java with Jakarta

Langchain4j is my favorite framework for working with large language models and Java. In the last couple of weeks, both Bazlur and I have presented to multiple user groups and conferences. This week, we had the privilege of presenting at the Jakarta Tech Talk, which both of us were looking very much forward to.

We now have so much demo code on the topic that we cannot present all the variations in one hour. We are still building along as we learn here.


Migrating JavaEE apps using Generative AI and Konveyor AI

Static code analysis + Gen-AI

Konveyor AI is a tool used to migrate Java applications to different Java frameworks, such as from JavaEE to Quarkus or Spring or from Spring 5 to 6, using Generative AI and static code analysis. I wrote a detailed post about this last year for the Java Advent Calendar.

Most recently, we have all been hard at work, bringing a preview for our community of users. In this post, I will outline how you can install and configure Konveyor AI using OpenAI and make meaningful generations. However, I have chosen OpenAI for the sake of simplicity in this post. Users can choose many other models, which are documented here.


Java + LLMs: A hands-on guide to building LLM Apps in Java with Jakarta

Java is an amazing language to work with. Millions of developers use it for daily work routines, and many mission-critical applications run on Java today. Whether we talk about banks, stock exchanges, or space, Java is prevalent and a language of choice.

With the advent of Large Language Models(LLM), new opportunities are at play. While Python has been the dominating language runtime for apparent reasons, there is a misconception that creating applications, agents, or other components for LLMs should also be done in Python. Most of the integration in LLMs is achieved by using REST API. Java is not short on anything in that space. System integration has been pretty awesome in Java, with many tools in that space. So why not Java?