Hi Santanu,
Unfortunately, this is not a well-documented area, but it is
possible.  Here's the high-level view, but don't expect these
instructions to be sufficient:

1. Put (:gen-class) in the (ns...) declaration in your .clj file.

2. Add a -main function like:  (defn -main [& args] ...)

3. Compile your namespace with (compile...)  This generates .class
files.

4. Run your class with "java your.namespace.name"

5. (Optional)  Use jar or ant to create a .jar file with a manifest
that specifies your class as the Main-Class.

No, this is not easy.  You need to know Java pretty thoroughly to have
any hope of success.  At some point I hope to write an article with
more details.  In the mean time, search the list to learn about gen-
class and compile.

-Stuart Sierra



On Apr 29, 7:04 am, Santanu <thisissant...@gmail.com> wrote:
> Hi Everybody,
>
> I wanted to compile a .clj clojure file into a .jar/.class file so
> that I could run it using java. (I don't know what is the actual way
> to run clojure file. So far, I have only been trying it from within
> emacs/slime).
>
> But I don't know how to create the .class/.jar file. I also don't know
> how to use ant (is that required?). I know javac can be applied on
> a .java file to get a .class file... but I dunno what applies to
> a .clj file?
>
> Kindly suggest how do I do this. Any pointer(s) to a suitable online
> article would be great.
>
> Thanks in advance for your help.
>
> Reards,
> Santanu Chatterjee
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to