A Brief Beginner's Guide To Clojure
← prev | next →     Top-level ToC     /distributing-apps.html     (printable version)

In the development environment chapter, it was noted that you can create and install a runnable jar of your Clojure app like so:

cd path/to/my-app
lein uberjar
cp target/my-app-0.1.0-standalone.jar ~/bin

Running the app in the typical way from the command line 1 takes a lot of typing though:

java -jar ~/bin/my-app-0.1.0-standalone.jar arg1 arg1 whatever

To make it easier for you and your friends to run your app, create a little script named after it:

cd ~/bin
touch my-app.sh
chmod +x my-app.sh

and into it put the following:


java -jar ~/bin/my-app-0.1.0-standalone.jar "$@"

When you send your jar to a friend, send this script along as well. Both the jar and the script should go into the ~/bin directory. Now, running your app is as easy as:

my-app.sh arg1 arg2 whatever

  1. Note that some OS’s may allow you to simply double-click on a jar file to run it. For those OS’s — and if your program does not need to be passed any options or arguments — the script described herein is not necessary.