views:

187

answers:

3

say i create a program in clojure and i have to deliver it to a client. the client does have some computer knowledge but he does not know/want to start the repl, load my program, and run it. he wants to double click an exe file or run a shell script

how do i package my program and deliver (the program itself with the clojure jars) ?

+15  A: 

You have a few choices:

  • Compile the program into Java classes, and give one a main method. Package them into an executable jar.
  • Per above, if you use Leiningen then you can assemble everything nicely with lein uberjar, making sure that you have declared a main class.
  • You can alternately package your project into a non-executable jar (no main class) and create a shell script/batch file to execute the proper class e.g. java -cp ./clojure.jar:./myprogram.jar com.my.runthis.class
  • Just package your .clj files into a jar, and use a shell/batch script to start a repl and then automatically issue commands e.g. java -cp ./clojure.jar:./myprogram.jar clojure.main -e "(in-ns 'your-ns)(start-your-program)" -r
Greg Harman
about the parameters to clojure.main :-e means execute ?-r means what ?where can i read about them ?thx
Belun
-e means evaluate -r means launch a repl. Options are described at http://clojure.org/repl_and_main
Greg Harman
+6  A: 

Simplest approach would be to let leiningen handle the jar for you it will package everything into a single fat jar thats all you need to deliver just like any other java app. All client has to do is double click on it. If you need an .exe file launch4j can create it for you, it can also handle JRE installation is it is not already installed on the clients machine. You don't need any bash scripts etc.

Hamza Yerlikaya
+5  A: 

You can use leiningen to create uberjar, as Greg Harman wrote... I personally use maven to create standalone jar with all dependencies, declare main class - this simplify run of it with 'java -jar your-jar-file' command. I also use Izpack to create installers for my programs

Alex Ott