Installing the environment
Duration: 10 min Prerequisites: chapter 05b, a PowerShell 7 terminal open.
Key idea
Section titled “Key idea”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 three tools to install
Section titled “The three tools to install”1. PowerShell 7 (recommended)
Section titled “1. PowerShell 7 (recommended)”The native Windows terminal (cmd, powershell) works, but PowerShell 7 is cleaner:
winget install Microsoft.PowerShellClose and reopen a PowerShell 7 window for the rest.
2. Ollama
Section titled “2. Ollama”If you followed the Ollama quickstart, you already have it. Otherwise:
winget install Ollama.OllamaVerify:
ollama --versionAnd check that the server runs (llama icon in the Windows tray, or via ollama serve):
curl.exe http://127.0.0.1:11434/api/tagsYou should get a JSON answer. If not, open Ollama from the Start menu.
3. Python 3.10+
Section titled “3. Python 3.10+”winget install Python.Python.3.12Verify:
python --version # must show 3.10 or higherpy --version # PEP 397 launcher, used by the scripts4. JDK 21
Section titled “4. JDK 21”winget install Microsoft.OpenJDK.21Close and reopen PowerShell so the PATH refreshes, then verify:
java -versionjavac -versionClassic gotcha:
java -versionmay work whilejavac -versionfails. That means you have a JRE (runtime) but not the JDK (compiler). UseMicrosoft.OpenJDK.21(which is a JDK) and not a plain JRE.
Four-line recap
Section titled “Four-line recap”winget install Microsoft.PowerShellwinget install Ollama.Ollamawinget install Python.Python.3.12winget install Microsoft.OpenJDK.21Close/reopen PowerShell, then run this smoke test:
ollama --versionpython --versionjavac -versionAll three must answer. If they do, the environment is ready.
Get the demos
Section titled “Get the demos”Each demo is a standalone GitHub repository under github.com/gneuroneai. Pick the one you want and clone it:
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 comparatorgit 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.gitOr 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.
The start.ps1 script that does everything
Section titled “The start.ps1 script that does everything”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:
cd ollama-demo-4-trio-agents-java.\start.ps1The first run takes ~5 minutes (model download ~4.7 GB + JUnit jar ~3 MB). Subsequent runs are nearly instant.
Useful modes:
.\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 busyTo stop cleanly:
.\stop.ps1And for demo 3?
Section titled “And for demo 3?”Simpler, no Streamlit UI, no JUnit. The manual route takes ~30 seconds:
git clone https://github.com/gneuroneai/ollama-demo-3-agent-java.gitcd ollama-demo-3-agent-javapy -m venv .venv.\.venv\Scripts\activatepip install -r requirements.txtollama pull llama3.1:8b # if not already donepython agent_java.pyYour PowerShell prompt must now start with (.venv) when the venv is active.
Final check
Section titled “Final check”Before moving to the practical chapters, run this minimal test to make sure everything is wired:
cd ollama-demo-3-agent-java.\.venv\Scripts\activatepython -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.
If something breaks
Section titled “If something breaks”| Symptom | Cause | Fix |
|---|---|---|
ModuleNotFoundError: No module named 'ollama' | venv not activated | .\.venv\Scripts\activate then pip install ollama |
ConnectionError / ECONNREFUSED 11434 | Ollama not running | Open Ollama from the Start menu |
'javac' is not recognized | JDK not in PATH | Close/reopen PowerShell after winget install Microsoft.OpenJDK.21 |
winget does nothing | App Installer outdated | Open the Microsoft Store, update it |
start.ps1 refuses to run | Execution policy | Set-ExecutionPolicy -Scope CurrentUser RemoteSigned (one time) |
| Slow Ollama download | Bandwidth | Be patient the first time, it’s ~4.7 GB |
Key takeaways
Section titled “Key takeaways”- Three tools: Ollama, Python 3.10+, JDK 21. Four
winget install. - Each demo’s
start.ps1automates everything, idempotent. - Once
start.ps1ran successfully, you never need to revisit it except to relaunch. - For issues, check the table above: 90 % of problems are listed there.