On Oct 16, 2009, at 8:12 AM, Folcon wrote:

Is there a cannonical way to create executable jar files?

I've uploaded a shell script that builds an example executable jar file to

  http://groups.google.com/group/clojure/web/build-executable-jar.sh

Here's the program the executable jar runs (example/hello.clj):

  (ns example.hello (:gen-class))
  (defn -main [& args]
    (apply println "hi" args))

Here's the script's output which traces its operation:

% sh build-executable-jar.sh clojure.jar
+ CLOJURE_JAR=clojure.jar
+ echo staging
staging
+ rm -rf /tmp/stage
+ mkdir -p /tmp/stage/src/example /tmp/stage/classes
+ echo writing Clojure source for main function
writing Clojure source for main function
+ cat
+ echo copying clojure.jar
copying clojure.jar
+ cp clojure.jar /tmp/stage
+ echo entering stage
entering stage
+ cd /tmp/stage
+ echo compiling
compiling
+ java -cp clojure.jar:classes:src clojure.main -e '(compile '\''example.hello)'
example.hello
+ echo testing using clojure.jar, class files
testing using clojure.jar, class files
+ java -cp clojure.jar:classes example.hello my name is
hi my name is
+ echo unpacking clojure.jar
unpacking clojure.jar
+ cd classes
+ jar -xf ../clojure.jar
+ echo building manifest
building manifest
+ echo 'Main-Class: example.hello'
+ echo building jar file
building jar file
+ jar -cmf manifest hello.jar -C classes clojure -C classes example
+ echo testing using hello.jar
testing using hello.jar
+ java -jar hello.jar success
hi success
%

--Steve

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to