views:

311

answers:

4
+3  Q: 

Compile Clojure?

I am new to clojure and I have tried to compile it last night but I couldn't seem to do it and I have no idea. I am on windows and don't know much about java. I just want a stand-alone file that I can give to my friends. (I know they need java) Can anyone help?

+2  A: 

How about an all in one Clojure installer for Windows? Unless I misunderstood your question and you want your Clojure files themselves compiled.

If you want to compile your own Clojure files, you can read this explanation on the Clojure site.

Maurits Rijk
I mean clojure programs.
GummyBEARZ
Ok, added some info in my answer
Maurits Rijk
+1  A: 

for producing a stand alone clojure program Leiningen's uberjar option does just that! Install leiningen and then run:

lein uberjar

and you get a single file that your friends can use to run your program.

Arthur Ulfeldt
+5  A: 

The easiest way would be to use Leiningen. You can make a very simple project.clj file for your project with :main pointing to your main file's namespace, and then you could do 'lein uberjar' on the command-line and it would stick all your dependencies in a single executable jar file.

I'll point out that every file that needs to be compiled must have a namespace with :gen-class enabled. For example:

(ns whatever.main
  (:gen-class))
Rayne
Nice, I didn't know about Leiningen.
Maurits Rijk
Thank you so much, you are amazing.
GummyBEARZ
@GummyBEARZ Well, I do try. ;)
Rayne
A: 

If you are a gradle user, you might be interested in Clojuresque (source at bitbucket). It provides similar to leiningen an ueberjar task, which packages up all necessary dependencies in a single jar. It allows easy compilation as well as simple deployment to Clojars. (Although this does currently not work on Windows.)

kotarak
Clojuresque was the first time I had ever heard of Gradle. I need to try it out sometime. The idea of build scripts in Groovy don't exactly excite me though. :)
Rayne
Gradle makes it very easy to have multiproject builds. Killer-feature for me. The Groovy part... who cares? Build scripts in Clojure also don't blow me off the chair.
kotarak