Skip to content

Installing the environment

Duration: 10 min Prerequisites: chapter 05b, a PowerShell 7 terminal open.

To run both demos, you need three tools: Ollama (the LLM engine), Python 3.10+ (the agent code), and a JDK 21 (for javac and java). Once they’re in place, the repo’s start.ps1 script does the rest.


The native Windows terminal (cmd, powershell) works, but PowerShell 7 is cleaner:

Terminal window
winget install Microsoft.PowerShell

Close and reopen a PowerShell 7 window for the rest.

If you followed the Ollama quickstart, you already have it. Otherwise:

Terminal window
winget install Ollama.Ollama

Verify:

Terminal window
ollama --version

And check that the server runs (llama icon in the Windows tray, or via ollama serve):

Terminal window
curl.exe http://127.0.0.1:11434/api/tags

You should get a JSON answer. If not, open Ollama from the Start menu.

Terminal window
winget install Python.Python.3.12

Verify:

Terminal window
python --version # must show 3.10 or higher
py --version # PEP 397 launcher, used by the scripts
Terminal window
winget install Microsoft.OpenJDK.21

Close and reopen PowerShell so the PATH refreshes, then verify:

Terminal window
java -version
javac -version

Classic gotcha: java -version may work while javac -version fails. That means you have a JRE (runtime) but not the JDK (compiler). Use Microsoft.OpenJDK.21 (which is a JDK) and not a plain JRE.


Terminal window
winget install Microsoft.PowerShell
winget install Ollama.Ollama
winget install Python.Python.3.12
winget install Microsoft.OpenJDK.21

Close/reopen PowerShell, then run this smoke test:

Terminal window
ollama --version
python --version
javac -version

All three must answer. If they do, the environment is ready.


Each demo is a standalone GitHub repository under github.com/gneuroneai. Pick the one you want and clone it:

Terminal window
cd $env:USERPROFILE\Documents
# Demo 0 — minimal CLI chat (~50 lines)
git clone https://github.com/gneuroneai/ollama-demo-0-chat-cli.git
# Demo 1 — Streamlit chat (~200 lines)
git clone https://github.com/gneuroneai/ollama-demo-1-chat-streamlit.git
# Demo 2 — 3-way model comparator
git clone https://github.com/gneuroneai/ollama-demo-2-comparator.git
# Demo 3 — simple CLI agent (reference implementation of the agent loop)
git clone https://github.com/gneuroneai/ollama-demo-3-agent-java.git
# Demo 4 — three collaborating Java agents (complete multi-agent project)
git clone https://github.com/gneuroneai/ollama-demo-4-trio-agents-java.git
# This course's sources (optional, if you want to fork the docs)
git clone https://github.com/gneuroneai/ollama-course-llm-local.git

Or download a ZIP from each repository’s GitHub page and unzip it.

In a hurry? Demo 3 and demo 4 are sufficient on their own: demo 3 contains the reference implementation of the agent loop, and demo 4 builds on it with three collaborating agents.


Each demo has its own idempotent start.ps1: you can run it 10 times in a row, it checks what’s missing and installs only that, without breaking what’s already there.

For demo 4, here is what its start.ps1 does, in 6 steps:

[1/6] Checking Ollama at http://127.0.0.1:11434...
[2/6] Checking model llama3.1:8b... (ollama pull if missing)
[3/6] Setting up Python virtualenv .venv... (py -m venv .venv if missing)
[4/6] Installing Python dependencies... (pip install -r requirements.txt)
[5/6] Checking JUnit 5 standalone jar... (downloads to lib/ if missing)
[6/6] Starting the Streamlit UI on port 8502...

To run it:

Terminal window
cd ollama-demo-4-trio-agents-java
.\start.ps1

The first run takes ~5 minutes (model download ~4.7 GB + JUnit jar ~3 MB). Subsequent runs are nearly instant.

Useful modes:

Terminal window
.\start.ps1 # Streamlit UI (default), port 8502
.\start.ps1 -Mode cli # interactive CLI (no Streamlit)
.\start.ps1 -Setup # only install, do not launch
.\start.ps1 -Port 8600 # change port if 8502 is busy

To stop cleanly:

Terminal window
.\stop.ps1

Simpler, no Streamlit UI, no JUnit. The manual route takes ~30 seconds:

Terminal window
git clone https://github.com/gneuroneai/ollama-demo-3-agent-java.git
cd ollama-demo-3-agent-java
py -m venv .venv
.\.venv\Scripts\activate
pip install -r requirements.txt
ollama pull llama3.1:8b # if not already done
python agent_java.py

Your PowerShell prompt must now start with (.venv) when the venv is active.


Before moving to the practical chapters, run this minimal test to make sure everything is wired:

Terminal window
cd ollama-demo-3-agent-java
.\.venv\Scripts\activate
python -c "from ollama import Client; c = Client(); print(c.list())"

You should see the list of your installed models, including llama3.1:8b. If the list shows up, the Python ↔ Ollama bridge works and we can attack the demos.


SymptomCauseFix
ModuleNotFoundError: No module named 'ollama'venv not activated.\.venv\Scripts\activate then pip install ollama
ConnectionError / ECONNREFUSED 11434Ollama not runningOpen Ollama from the Start menu
'javac' is not recognizedJDK not in PATHClose/reopen PowerShell after winget install Microsoft.OpenJDK.21
winget does nothingApp Installer outdatedOpen the Microsoft Store, update it
start.ps1 refuses to runExecution policySet-ExecutionPolicy -Scope CurrentUser RemoteSigned (one time)
Slow Ollama downloadBandwidthBe patient the first time, it’s ~4.7 GB

  • Three tools: Ollama, Python 3.10+, JDK 21. Four winget install.
  • Each demo’s start.ps1 automates everything, idempotent.
  • Once start.ps1 ran successfully, you never need to revisit it except to relaunch.
  • For issues, check the table above: 90 % of problems are listed there.