Other stacks
Same recipe, different bootstrap: Node CLI · Python · Web Component · REST API (Node) · Go · Rust
JVM · Estimated time: ~15 min · Karajan iterations: 2–3
This walkthrough takes you from an empty directory to a merged feature on a small Java CLI project (Maven + JUnit 5). It also covers the Gradle variant — the only differences are the wrapper and the test command.
You should already have done the common setup: npm install -g karajan-code, kj init inside the project, and a green kj doctor. If kj doctor is red, fix that first — kj run will refuse to start otherwise.
You’ll also need JDK 17+ (java --version) and either Maven 3.8+ (mvn --version) or a Gradle wrapper.
Bootstrap the project.
mkdir hello-java && cd hello-javamvn -q archetype:generate -DgroupId=dev.kj.hello \ -DartifactId=hello-java -DarchetypeArtifactId=maven-archetype-quickstart \ -DinteractiveMode=falsemv hello-java/* . && rm -rf hello-javagit init -b main && git add -A && git commit -m "chore: scaffold"Open pom.xml and bump JUnit to 5, plus add the surefire plugin so mvn test runs JUnit 5:
<properties> <maven.compiler.source>17</maven.compiler.source> <maven.compiler.target>17</maven.compiler.target> <junit.version>5.10.2</junit.version></properties>
<dependencies> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter</artifactId> <version>${junit.version}</version> <scope>test</scope> </dependency></dependencies>Initialize Karajan in the repo.
kj initkj doctorkj init creates .karajan/ and writes the orchestrator config; kj doctor confirms the agent CLIs, Docker, Ollama, ports, and detects the JDK + build tool.
Describe the feature in natural language.
No spec file. No JSON. Just the task as you’d describe it to a colleague:
kj run "Add a static method 'greet(String name)' to \src/main/java/dev/kj/hello/Greeter.java that returns 'Hello, <name>!'. \Add a JUnit 5 test in src/test/java/dev/kj/hello/GreeterTest.java \that asserts the output for the name 'world'." \ --methodology tdd \ --coder claude \ --reviewer codex \ --reviewer-fallback claude \ --max-iterations 5Watch the run on the HU Board.
Open http://localhost:4000 in another tab while the pipeline runs. You’ll see, in real time:
You can also tail the same trace in the terminal:
kj tailInspect the result.
git statusgit diff --statmvn testExpected output of mvn test:
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0[INFO] BUILD SUCCESSMerge.
Karajan does not push or merge for you by default — that’s your call. When you’re happy with the diff:
git checkout -b feat/greetergit add -A && git commit -m "feat: add Greeter.greet(name)"git push -u origin feat/greetergh pr create --fillOr, if you want Karajan to also open the PR for you, add --auto-commit --auto-pr to the kj run invocation.
Same flow, different build tool. Bootstrap with the Gradle wrapper:
mkdir hello-java && cd hello-javagradle init --type java-application --dsl kotlin --test-framework junit-jupitergit init -b main && git add -A && git commit -m "chore: scaffold"Then run the same kj run invocation. Karajan auto-detects build.gradle.kts and uses ./gradlew test instead of mvn test.
The same run launched via the MCP from any MCP-capable client (Cursor, Claude Desktop, Codex):
{ "tool": "kj_run", "params": { "task": "Add a static method 'greet(String name)' returning 'Hello, <name>!'. JUnit 5 test.", "methodology": "tdd", "coder": "claude", "reviewer": "codex", "reviewerFallback": "claude", "maxIterations": 5 }}Add --mode strict and the deterministic security collectors:
kj run "<task>" \ --mode strict \ --enable-security \ --enable-sonarcloud \ --methodology tddThis wires the OSV-Scanner and Semgrep collectors into the audit (Java ruleset enabled), and gates the merge on the Sonar quality gate as well as the reviewer verdict. Sonar’s Java analyser is particularly strong on null-safety and resource leaks.
Other stacks
Same recipe, different bootstrap: Node CLI · Python · Web Component · REST API (Node) · Go · Rust
Back to the index
How-To index · setup + troubleshooting