Course map
Stage 1: Foundation
Stage 2: Intermediate
Stage 3: Advanced
Stage 4: DSA in Java
Stage 5: Specialization

Part 10 / Topic 2 of 12

JUnit 5 with no build tool: the console-standalone jar

JUnit 5 is not part of the JDK — import org.junit.jupiter.api.Test; will not compile until something puts JUnit's classes on the classpath. Real projects do this with Maven or Gradle, but this course does not reach Maven until Part 15. The honest, no-build-tool way is the JUnit Platform Console Launcher: one jar that bundles the test engine and a command-line runner, so javac and java can use it exactly like any other classpath dependency.

Pinned version: junit-platform-console-standalone 1.14.5 (the JUnit Console Launcher, JUnit 5/Jupiter line — see examples/lib/README.md for the download command and a SHA-1 check). Download it once into examples/lib/; every command below assumes it is sitting there.

$ java -jar junit-platform-console-standalone-1.14.5.jar --version
JUnit Platform Console Launcher 1.14.5
JVM: 21.0.11 (Amazon.com Inc. OpenJDK 64-Bit Server VM 21.0.11+10-LTS)
OS: Mac OS X 26.7.3 aarch64

(JVM/OS reflect your machine — (varies).)

Two things this one jar does for you:

  1. Compiling a test needs JUnit's annotations/assertions on the classpath: javac -cp junit-platform-console-standalone-1.14.5.jar MyTest.java.
  2. Running tests needs the same jar, but used differently — not java -cp jar MyTest (test classes have no main; more on this in Common Mistakes), but through the launcher's own execute command:
$ java -jar junit-platform-console-standalone-1.14.5.jar execute -cp . --scan-class-path --details=tree
  • -jar junit-platform-console-standalone-1.14.5.jar — run the launcher itself.
  • execute — the launcher's "run my tests" subcommand.
  • -cp . — where your compiled test classes are (here, the current folder).
  • --scan-class-path — "find every @Test on that classpath yourself," instead of naming classes one by one.
  • --details=tree — print a readable pass/fail tree, not just the final counts.

From here on, every transcript in this lesson also adds --disable-ansi-colors, purely so the ✔/✘ marks show up in this document instead of raw colour codes — your terminal shows the same tree in colour without that flag.

Done here? The practice set for Part 10 — including the solutions — is on the part page.

Search the guide