JAVA · SERIES · BEGINNER

Java for AI Engineers.

The Java skills you need to work with LLMs and build AI agents. Start with how models behave and a plain HttpClient call, then grow into Spring AI, LangChain4j, tools, MCP, RAG and agents. No Python, no maths.

PARTS
5
READING TIME
~42 min
LEVEL
beginner
WITH VIDEO
1 of 5

After this series you can

  • Explain where Java fits in AI work, and where Python is still the better tool.
  • Reason about tokens, context windows, temperature and statelessness, and fix the bugs they cause.
  • Call any OpenAI-compatible LLM, local or cloud, with plain HttpClient and Jackson, including errors, retries and streaming.
  • Use records, sealed types, pattern matching, text blocks and virtual threads to write clean, safe and fast AI code.
  • Build AI features with Spring AI: ChatClient, prompt templates, structured output, streaming, chat memory and model switching.
WHO IT'S FOR

Java developers who know the basics and REST APIs, and want to add AI features or build agents without switching to Python.

The path — 5 parts, in order

Every part also stands on its own.
  1. PART 01Why Java for AI? Where Java fits next to PythonPython trains the models. But most AI work today is building the app around a model, and that is the kind of work Java has done well for decades. Here is an honest map of who does what.8 min read
  2. PART 02How LLMs work: tokens, context windows and temperatureYou don't need the maths. You do need to know why the model forgets everything, why long chats cost more, and which temperature to use. Here is how an LLM works, explained for the Java code you will write.9 min read · ▶ video
  3. PART 03Call an LLM API from plain Java with HttpClient and JSONNo framework, no SDK. Just java.net.http.HttpClient, a few records and Jackson. One small client that talks to a local model or a cloud API by changing three settings, with error handling, retries and streaming.8 min read
  4. PART 04Java 21 features for AI apps: records, sealed types and moreLLM code has three hard parts: messy JSON, replies that come in many shapes, and calls that take seconds. Modern Java has a feature for each. Here is how records, sealed types, pattern matching, text blocks and virtual threads fit AI work.8 min read
  5. PART 05Spring AI ChatClient: prompts, templates and model switchingThe HTTP call from part 3, now done the Spring way. Set up Spring AI 2.0 with a local model, talk to it with ChatClient, use prompt templates, get Java records back, stream, remember the conversation, and switch providers without changing code.9 min read

Comes after Java Coding Interview Prep: 50 Problems in Order, Python for Java Developers.

Where to go next

AI · SERIESbeginner

Run LLMs locally with Ollama

Run a real language model on your own computer, then talk to it four ways: the command line, the desktop app, the REST API, and code in Python and Java. Every part also stands on its own.

8 PARTS · ABOUT 57 MIN

More Java series

All Java series →
SERIESbeginner

Java Coding Interview Prep: 50 Problems in Order

Rusty before a Java coding round? Solve 50 classic interview problems in an order that builds on itself: arrays, strings, collections, HashMap, Comparator, stacks and queues, then streams and the tricky stream puzzles interviewers love. Every problem has plain-English steps, clean code and the follow-up questions you will hear.

9 PARTS · ABOUT 41 MIN
SERIESbeginner

Python for Java Developers

Learn Python fast by building on the Java you already know. Each part takes one Python idea, gives you one quick Java comparison to anchor it, then teaches it in plain Python, with the traps a Java mind falls into. Short, practical, and aimed at the Python you meet in real AI code.

13 PARTS · ABOUT 63 MIN