The best AI agent framework for Java is LangChain4j for most beginners, and Spring AI if your project already runs on Spring Boot. Both are free, open source and work on Java 17 or newer.
You do not need to learn Python to build agents. Java has strong options now. Below you get a pick for each situation, the Java version each one needs, and a few lines of code so you can see how they feel.
Quick answer
- Best for Java beginners: LangChain4j. Plain Java, no Spring needed.
- Best for Spring Boot teams: Spring AI.
- Best for planned, explainable workflows: Embabel (needs Java 21).
- Best if you write Kotlin too: Koog from JetBrains.
- Best for Gemini and Google Cloud: Google ADK for Java.
- Best for Azure shops: Semantic Kernel for Java.
What you need before you start
Every framework here is free. You only pay for the AI model calls, unless you run a local model with Ollama, which costs nothing per call.
Install JDK 17 or newer
LangChain4j, Spring AI 2.x, Google ADK and Koog all need 17 or higher. Embabel needs 21. If you can, install 21 and use it for everything.
Use Maven or Gradle
Each framework is a normal dependency from Maven Central. Google ADK asks for Maven 3.9 or newer.
Get a model API key
Create a key with OpenAI, Anthropic, Google or another provider. Put it in an environment variable, never in your source code.
Set a spending cap
Set a monthly limit in your model account first. An agent that loops by mistake can burn money fast.
Do you need an agent framework at all?
Not always. An agent is a loop: the model picks an action, a tool runs, and the result goes back to the model. With one or two tools, a plain HTTP call to the model API is enough.
Use a framework when you need memory, many tools, several agents, safety checks, or a way to switch model providers. To understand the idea first, read what an AI agent framework is. For tools outside Java, see the full list of the best AI agent frameworks.
How each framework is judged
- Beginner friendliness: how fast a Java developer gets a working agent.
- Java fit: real Java code, not a port that feels foreign.
- Agent power: tools, memory, multi-agent flows, protocols like MCP.
- Stability: is it GA, beta or experimental.
- Lock-in: does it force a model provider or a cloud.
Last updated: September 2026. Versions and status change often, so check the official page before you commit.
Comparison table
| Framework | Best for | Java version | Status | License |
|---|---|---|---|---|
| LangChain4j | Beginners, any Java stack | 17+ | GA, agent module experimental | Apache 2.0 |
| Spring AI | Spring Boot apps | 17+ | GA | Apache 2.0 |
| Embabel | Planned workflows | 21+ | Early stage | Apache 2.0 |
| Koog | Kotlin and Java teams | 17+ | Stable, Kotlin first | Apache 2.0 |
| Google ADK | Gemini, Google Cloud | 17+ | Pre-GA | Apache 2.0 |
| Semantic Kernel | Azure OpenAI | Check docs | Maintained by Microsoft | MIT |
The best AI agent frameworks for Java
LangChain4j
Best for beginners- Best forJava beginners, any framework
- PriceFree, open source
- Java17 or newer
LangChain4j is not a port of the Python LangChain. It is built for Java. You write an interface, add annotations, and the library builds the agent behind it. It supports 20+ model providers and 30+ vector stores, and works with Spring Boot, Quarkus, Helidon and Micronaut.
Its agentic module adds sequential, loop, parallel and conditional flows, plus a supervisor agent that picks the next step. It also has guardrails for checking input and output.
Pros
- Works with or without Spring
- Widest provider and vector store support
- Simple interface-based style
Cons
- The agentic module is still marked experimental
- Some modules carry beta version numbers
- New provider features can arrive a few weeks late
LangChain4j example
This agent has one tool. The model can call it when the user asks for the time.
Java code
interface Assistant {
@SystemMessage("You are a helpful assistant.")
String chat(String message);
}
class TimeTools {
@Tool("Returns the current time")
String now() { return java.time.LocalTime.now().toString(); }
}
var model = OpenAiChatModel.builder()
.apiKey(System.getenv("OPENAI_API_KEY"))
.modelName("gpt-4o-mini")
.build();
Assistant agent = AiServices.builder(Assistant.class)
.chatModel(model)
.tools(new TimeTools())
.build();
System.out.println(agent.chat("What time is it?"));
Spring AI
Best for Spring Boot- Best forTeams already on Spring Boot
- PriceFree, open source
- Java17 or newer
Spring AI uses what Spring developers already know: dependency injection, auto-configuration and starters. You mark a method with @Tool, inject a ChatClient, and you have an agent. It supports OpenAI, Anthropic, Amazon Bedrock, Google, Ollama and more, plus MCP, structured output and RAG.
Check the version match first. Spring AI 2.x needs Spring Boot 4.x. Spring AI 1.1.x needs Spring Boot 3.5.x.
Pros
- Feels native inside Spring Boot
- Good observability and auto-configuration
- Backed by the Spring team
Cons
- Best value only if you use Spring
- Version must match your Spring Boot version
- Fewer providers than LangChain4j
Spring AI example
Java code
class TimeTools {
@Tool(description = "Returns the current time")
String now() { return java.time.LocalTime.now().toString(); }
}
String answer = ChatClient.builder(chatModel).build()
.prompt()
.user("What time is it?")
.tools(new TimeTools())
.call()
.content();
Embabel
Best for planning- Best forExplainable multi-step workflows
- PriceFree, open source
- Java21 or newer
Embabel is built on Spring for Java and Kotlin. Instead of letting the model decide every step, it uses a planning algorithm (GOAP) to pick actions that reach a goal, and it replans after each step. That makes flows easier to test and explain.
Pros
- More predictable than free-form loops
- Strong typing and easy testing
- Can mix different models per step
Cons
- Early stage, expect changes
- Needs Java 21
- New concepts to learn first
Koog
Best for Kotlin- Best forKotlin-friendly teams, long workflows
- PriceFree, open source
- JavaJDK 17 or newer
Koog is JetBrains’ agent framework. It is Kotlin first, with a Java API. It models flows as graphs, saves state so a workflow can resume after a failure, and compresses long chat history to save tokens.
Pros
- Checkpointing for fault tolerance
- Works with OpenAI, Anthropic, Google, Ollama
- Runs on JVM, Android and more
Cons
- Docs and examples lean Kotlin
- Java code can feel less natural
Google ADK for Java
Best for Gemini- Best forGemini and Google Cloud teams
- PriceFree, open source
- Java17 or newer, Maven 3.9+
ADK is code-first and built for multi-agent systems. It comes with a local web UI to trace and test agents. The quickstart uses Gemini, so it fits best if you are already on Google Cloud.
Pros
- Made for multi-agent design
- Built-in dev UI for debugging
Cons
- Marked pre-GA, so no stability promise
- The dev UI is not for production
- Gemini first
Semantic Kernel for Java
Best for Azure- Best forAzure OpenAI teams
- PriceFree, open source (MIT)
- JavaSee the repo for the current minimum
Semantic Kernel is Microsoft’s SDK. You define plugins and chain them together. It suits companies that run on Azure. The Java version follows the C# design, so it can feel heavier than LangChain4j.
Pros
- Microsoft backing
- Good Azure fit
Cons
- Less Java-style than the others
- Not the first pick outside Azure
How to choose
- You are new to AI agents: pick LangChain4j. It has the gentlest start.
- Your app is Spring Boot: pick Spring AI, and match the version to your Boot version.
- You use Quarkus or Micronaut: pick LangChain4j.
- You want predictable, testable flows: try Embabel on a side project first.
- You need workflows that resume after a crash: look at Koog.
- Your models are Gemini on Google Cloud: use Google ADK.
- Your company standard is Azure: use Semantic Kernel.
If you also work in Python, the Python framework guide shows how the same ideas look there. For a wider view, see the frameworks for AI development list.
Free vs paid: what you really pay
The frameworks cost nothing. Your bill is the model. Small models are cheap for learning. To pay nothing per call, run a model locally with Ollama, which Spring AI and Koog support.
Watch out
Set a max number of steps and a spending cap. An agent that keeps calling tools can run up a large bill in minutes.
Mistakes to avoid
- Mixing versions. Spring AI 2.x on Spring Boot 3 will not work. Match them.
- Trusting experimental modules in production. Pin exact versions and read the release notes before upgrading.
- Hiding the prompt. Layers can hide the exact text sent to the model. Turn on logging so you can see it.
- Giving tools too much power. A tool that deletes data needs a human approval step.
- Starting with many agents. Build one agent with two tools first.
Our pick
Start with LangChain4j if you are learning or not on Spring. Choose Spring AI if your app already runs on Spring Boot. Keep Embabel, Koog and ADK for cases where their special strength, planning, checkpoints or Gemini, is what you need.
FAQ
Is Java good for AI agents?
Yes. You get strong typing, real multithreading for parallel tool calls, and easy fit with existing enterprise systems.
What is the best AI agent framework for Java beginners?
LangChain4j. It needs only JDK 17 and one dependency, and the interface style is easy to read.
LangChain4j or Spring AI?
Use Spring AI if you are on Spring Boot. Use LangChain4j for everything else or if you want more providers.
Do I need Python to build agents?
No. Every framework above is written for the JVM.
Are these frameworks free?
Yes, all are open source. You pay only for model API calls, or nothing with a local model.