Turning leiningen script into an executable

I used the venerable launch4j to wrap leiningen-standalone jar into an executable. You can get the Windows clojure binaries here.

There were a few problems along the way.

Clojure reports MethodNotFound

Leiningen already contains Clojure 1.2.1. If we intend to run Clojure 1.4, it has to appear on the classpath first. However, when Launch4j wraps a leiningen-standalone.jar, it is the first file that appears on the classpath. The solution is to specify clojure-1.4.0.jar as the main jar.

Launch4j couldn’t find clojure.jar

The documentation was incorrect. The location of the jar files were incorrectly stated to be relative to the exe file. In practice, the executable directory must be explicitly included. e.g. %EXEDIR%\clojure-1.4.0.jar

Other tricks

I was able to wrap clojure.jar into clojure.exe, which performs double-duty as a .jar file. I was able to include clojure.exe into the classpath to save disk space.

Download launch4j-clojure.zip

  <cmdLine>clojure.main -e "(use &apos;leiningen.core)(-main)" %@</cmdLine>
    <opt>-client </opt>