r/Clojure • u/SmartLow8757 • Jan 23 '26
clj-pack — Package Clojure apps into self-contained binaries without GraalVM
I built a tool to solve a problem I kept hitting: deploying Clojure apps without requiring Java on the target machine.23:20:00 [3/101]
The usual answer is GraalVM native-image, but in practice it means dealing with reflection configs, library incompatibilities, long build times, and a complex toolchain. For many projects it's more friction than it's worth.
clj-pack takes a different approach: it bundles a minimal JVM runtime (via jlink) with your uberjar into a single executable. The result is a binary that runs anywhere with zero external dependencies and full JVM compatibility — no reflection configs, no unsupported libraries, your app runs exactly as it does in development.
clj-pack build --input ./my-project --output ./dist/my-app
./dist/my-app # no Java neededHow it works:
- Detects your build system (deps.edn or project.clj)
- Compiles the uberjar
- Downloads a JDK from Adoptium (cached locally)
- Uses jdeps + jlink to create a minimal runtime (~30-50 MB)
- Packs everything into a single binary
The binary extracts on first run (cached by content hash), subsequent runs are instant.
Trade-off is honest: binaries are slightly larger than GraalVM output (~30-50 MB vs ~20-40 MB), and first execution has extraction overhead. But you get full compatibility and a simple build process in return.
Written in Rust, supports Linux and macOS (x64/aarch64).
https://github.com/avelino/clj-pack
Feedback and contributions welcome
View all comments
Show parent comment
3
u/SmartLow8757 Jan 23 '26
Yes, exactly! The output binary is a self-extracting executable: a shell stub + a compressed tar.gz payload appended together. The payload contains a minimal JVM runtime (built via jlink, typically ~30-50MB) and your app.jar.
On first execution, the stub extracts the payload to `~/.clj-pack/cache/{content-hash}/`. The cache key is a SHA256 hash of the payload content, so identical binaries always reuse the same cache. Subsequent runs detect the cache directory already exists and skip extraction entirely — going straight to `exec java -jar`.
If you rebuild your app (new code, new dependencies, different JDK version), the payload hash changes, which means a new cache entry. Old cache entries can be safely deleted manually if disk space is a concern.
The overhead is only on the very first run (or after you deploy a new version). After that, startup time is just the JVM boot + your app initialization — same as running `java -jar` directly
read more here https://avelino.run/clj-pack-distributing-clojure-without-the-graalvm-pain/