Browse Learn Clojure Foundations as a Java Developer

Your First Clojure Project

Create a small Clojure project that has a runnable entry point, test namespace, REPL-friendly functions, and a simple structure Java engineers can recognize and extend.

Your first Clojure project should be boring in a good way: a predictable folder layout, a namespace you can load, a function you can call from the REPL, and at least one test you can run.

What You Are Building Here

  • A src/ namespace that loads cleanly.
  • A test/ namespace that runs quickly.
  • A dependency file (deps.edn or project.clj) that you can extend later.
  • A simple entry point so you can run the code outside the REPL.
Project piece Why it belongs in the first project
One pure function Gives you something easy to call from the REPL and test directly
One -main entry point Shows how Clojure code runs as a JVM application
One test namespace Establishes the testing loop before the codebase grows
One dependency file Makes classpath and dependency changes explicit
One README command block Prevents “how do I run this?” friction for teammates

Java mental model: treat this as the smallest “Maven archetype” project, but optimized for interactive development.

Once you can create and run a tiny project end-to-end, you can iterate confidently in the later chapters without fighting your tools.

In this section

  • Build Your First Clojure Project
    Create a small Clojure project with a namespace, pure greeting function, runnable entry point, and repeatable command while mapping each piece to familiar Java concepts.
  • Understand Clojure Project Structure
    Map Clojure source paths, namespaces, tests, resources, and build files to the Java project concepts you already know so a small project stays easy to navigate.
  • Run and Test a Clojure App
    Run a small Clojure app from the command line, add focused clojure.test coverage, and create repeatable commands that feel predictable to Java engineers.
  • Package a Clojure App as an Uberjar
    Package a small Clojure application as an executable uberjar, understand when :gen-class and AOT compilation matter, and verify the artifact with java -jar.
Revised on Saturday, May 23, 2026