What to do with a .jar with no classes?

I was reading the tools.build guide and I learned how to create a jar with those tools. Great!.

The example shows me how to do that jar, but not what to do with it next.

The first thing I tried was to just run it: java -jar target/<the-jar>.jar. But the example didn’t create the class files.

I suppose I have to learn how to use the tools to compile the .clj files. It must be with the compile-clj function.

Cool. But now I’m wondering:

What is the use case of a .jar with no classes?

If you built an uber JAR, it will have all your dependencies as well as your project and it will have Clojure too. That means you can run:

java -cp target/<the-jar>.jar clojure.main -m your.ns

That will run Clojure’s main function and tell it to call the -main function in your.ns (whatever the entry point in your project is).

All of this is explained in the docs for depstar which you may find helpful, even though you are building JARs with tools.build: Readme — com.github.seancorfield/depstar 2.1.267

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.