r/JavaProgramming • • 1d ago

You don't need Spring AI to build AI-powered Java applications

With all the recent attention around Spring AI, I think it's worth highlighting LangChain4j as a framework-independent alternative.

LangChain4j provides many of the same capabilities: chat, structured output, tool calling, RAG, conversation memory, streaming and MCP. You can use it with virtually any Java framework or just plain Java.

I recently put together a small integration example using CoilBase and Jex. No dedicated integration module, DI container or Spring dependencies. Just ordinary Java services and constructor wiring.

The example verifies chat, structured output mapped to a Java record, automatic tool calling and HTTP application lifecycle. It uses a mock model, so no API keys or paid LLM calls are needed to reproduce the tests.

I also included a table mapping common Spring AI capabilities to LangChain4j.

Integration guide:
https://github.com/PVRLabs/coilbase/blob/main/docs/langchain4j.md

Working example and tests:
https://github.com/PVRLabs/experiments/tree/main/java/coilbase/langchain4j-recipe

The same approach can be adapted to other Java frameworks.

Anyone here using LangChain4j outside the Spring ecosystem? How has your experience been?

6 Upvotes

3 comments sorted by

2

u/tenken01 23h ago

Yep, I’ve used it in production in two products that are used daily. I really like it and have no complaints.

1

u/fykup 22h ago

Nice! Are you running LangChain4j inside a specific Java framework, or just using it standalone? Also what features have actually been useful for you in production?

1

u/fykup 1d ago

Small update: I've also published a coilbase-development skill for coding agents. It includes architectural guidance, API references and a link to the LangChain4j integration recipe.

If you want to experiment with this stack, install the skill:

npx skills add ejboy/agent-scripts --global --skill coilbase-development

Then ask your coding agent to build an AI-powered Java application using CoilBase and LangChain4j.

https://github.com/ejboy/agent-scripts/blob/main/skills/coilbase-development/SKILL.md