The other way is to create a uberjar:
> lein clean
> lein uberjar
Compiling demo.hello
Compiling demo.numbers
Created /home/alan/expr/demo-horizon/target/demo-horizon-0.1.0-SNAPSHOT.jar
Created /home/alan/expr/demo-horizon/target/demo-horizon-0.1.0-SNAPSHOT-standalone.jar
You normally always want to use the xxx-standalone.jar
version.
Then you start the process using plain java w/o any lein at all:
java -jar /home/alan/expr/demo-horizon/target/demo-horizon-0.1.0-SNAPSHOT-standalone.jar
and you can add any flags like -Xmx4g
or whatever else you like.
Update
I always run lein clean
before creating a uberjar. This is the default behavior, but can be disabled by setting :auto-clean false
in project.clj
. According the the Sample project.clj:
; By default Leiningen will run a clean before creating jars to prevent
; undeclared AOT from leaking to downstream consumers; this disables
; that behaviour.
:auto-clean false
I cannot see why starting with a dirty build would ever be a good idea, which is why I always manually run lein clean
first (just in case :auto-clean
has been disabled).