Fork me on GitHub
#java
<
2022-10-26
>
Noah Bogart17:10:27

what does it mean to create multiple jars instead of a single uberjar? how do they interact? How do you deploy? The mental model for an uberjar is pretty easy: everything's in one place and is updated together. But when building multiple jars in multiple sub projects (of a java or clojure app), I struggle to understand how it all works together. If anyone has articles or blog posts that talk about this, I'd love to read them.

Alex Miller (Clojure team)18:10:51

if you're deploying, then you need the N jars on the classpath. so, you can gather them up and deploy them onto a server, then put them on the classpath. If you start with java directly, there is limited wildcard support on the classpath so you can just java -cp libs/* my.Main

Noah Bogart18:10:07

Oh, right, then the jars just act like dependencies/namespaces and your code sees them by the same means clojure code sees another namespace (because clojure effectively relies on java's resolution system). Okay, that makes sense. I was thinking of, like, binary executables that don't have their internals exposed but this makes more sense.

Alex Miller (Clojure team)18:10:42

this makes it possible to update just things that change at finer-grain (Datomic ions does some stuff like this under the hood), but is maybe more cumbersome than it's worth for most deployments

Noah Bogart18:10:56

The app would still have to restart, but you'd only have to ship the single jar? Or can you do hot-reloading with jars?

Alex Miller (Clojure team)18:10:42

without something special, you would need to restart (there are capabilities for hot loading via java agents, but lots of caveats there)

👍 1
Noah Bogart18:10:01

cool, thanks for the help