incidentally, I seem to remember that the enclojure netbeans plugin does all
this for you, and even outputs the exact command you need to run to execute.

a default project starts with such a -main.  That said, it's probably not a
good way to really understand what's going on ... if that's a goal.

On Wed, Apr 29, 2009 at 2:36 PM, Santanu <thisissant...@gmail.com> wrote:

>
> Thanks everyone for your suggestions.
> I somehow managed to compile my first clojure program, generating a
> class file that I could run using java.
> I started with the overview provided by Stuart Sierra, and read the
> article pointed by Raphaƫl. Didn't work at first, but after some trial
> and error, it worked somehow. The main problem is that I don't know
> any Java yet (I just started reading Core Java vol.1 as suggested by
> this group a few days ago).
>
> Anyways, I am mentioning the process I used. Please suggest any better
> (shorter/simpler) ways if you feel this is not the right way to do it.
>
> 1. I created a simple test2.clj file in my $HOME:
> -----------------------
> (ns test2
>  (:gen-class))
>
> (defn -main [& args]
>  (println "Hello, world of Clojure!"))
> ------------------------
>
> 2. I started a clojure REPL, from a terminal:
> ------------------------
> sant...@lenny:~$ java -cp /home/santanu/:/opt/clojure/clojure.jar
> clojure.lang.Repl
> ------------------------
>
> 3. Inside the REPL, I compiled my program using:
> ------------------------
> (binding [*compile-path* "/home/santanu"]
>  (do
>    (load-file "test2.clj")
>    (compile 'test2)))
> ------------------------
>
> 4. Got out of the REPL, and ran the program using:
> ------------------------
> sant...@lenny:~$ java -cp ./:/opt/clojure/clojure.jar test2
> Hello, world of Clojure!
> ------------------------
>
> One thing I noticed was that the above run takes an aweful amount of
> time to run, much much more than a similar compiled java program:
>
> -------------------------
> sant...@lenny:~$ time java -cp /home/santanu/:/opt/clojure/clojure.jar
> test2
> Hello, world of Clojure!
>
> real    0m1.093s
> user    0m0.952s
> sys     0m0.064s
>
> sant...@lenny:~$ time java Test
> Hello, World of Java!
>
> real    0m0.105s
> user    0m0.040s
> sys     0m0.008s
> -------------------------
> I think I am definitely missing something here.
>
> Regards,
> 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