How to compile in Clojure ========================= 1. Set up your build tree ------------------------- . |-- classes | |-- clojure | | ... | | |-- contrib | | ... | `-- org | `-- salvipeter | |-- ScheherazadeRegOT.ttf | `-- buckwalter.txt |-- compile |-- compile.clj |-- manifest.txt `-- src `-- org `-- salvipeter `-- ArabicDictionary.clj [here ScheherazadeRegOT.ttf and buckwalter.txt are data used by the program] 2. `compile' script contents ---------------------------- #!/bin/bash java -cp classes:src clojure.lang.Script ./compile.clj jar cfm ArabicDictionary.jar manifest.txt -C classes clojure -C classes org [most of the time you should only change the name of the JAR file] 3. `compile.clj' script contents -------------------------------- (compile 'org.salvipeter.ArabicDictionary) 4. `manifest.txt' configuration ------------------------------- Main-Class: org.salvipeter.ArabicDictionary [note that it requires a newline at the end] 5. Changes in the source code ----------------------------- i) The namespace should be path.to.file.filename, so here it is org.salvipeter.ArabicDictionary, and we also need a :gen-class option, so: (ns org.salvipeter.ArabicDictionary (:use ...) (:import ...) (:gen-class)) ii) Create a -main function: (defn -main [& args] ...) iii) URIs and streams for files inside the archive can be obtained by (def class-loader (ClassLoader/getSystemClassLoader)) ;;; URI: (.getResource class-loader "org/salvipeter/buckwalter.txt") ;;; InputStream: (.getResourceAsStream class-loader "org/salvipeter/ScheherazadeRegOT.ttf") 6. Just run the compile script ------------------------------