> Hello clojure developers,
> I had a question regarding jar-ring up clojure generated source using
> gen-class.
>
> When I do a gen-class, and say either :main is true, or add a -main
> method, the class file that gets generated always has a random prefix.
One important need filled by gen-class is exactly this case: you need
a class with a name you can specify completely and use elsewhere.
> I need to enter the Main class in a jar's Manifest, and was wondering
> how you guys have done it.
There's an example at clojure.contrib.repl_ln.clj. It uses just "(:gen-
class)" (no options) in its "ns" declaration:
(ns
...
clojure.contrib.repl-ln
(:gen-class)
...)
(defn- -main
"Main entry point, starts a repl enters the user
namespace and processes command line args."
[& args]
(repl :init
(fn []
(println "Clojure" (clojure-version))
(in-ns 'user)
(process-command-line args))))
(this could also have been defn rather than defn- and would behave the
same regarding being callable from Java)
When compiled, this produces the class file:
clojure/contrib/repl_ln.class
You can see it in clojure.contrib.jar (either using a tool that can
display its contents directly or bar unjarring it: jar xvf
clojure.contrib.jar)
If the example above doesn't lead you to a solution, please post more
particulars and a simplified example that shows the problem you're
seeing.
--Steve