3

I'm trying to understand how to package a command line application written in Clojure for distribution. I don't want users to have to use java -jar myproject.jar arg1 arg2 to run the program. PHP has something called "Phar" files, which are basically executable zip files, so they include a shebang that tells POSIX systems how to unpack and run them.

I've seen other Clojure apps that allow the jar file to be set chmod +x and then executed directly. How do they achieve this? Uberjar just seems to make a jar that requires the java -jar prefix.

d11wtq
  • 34,788
  • 19
  • 120
  • 195

2 Answers2

9

You can do this using lein-bin.

bsvingen
  • 2,699
  • 14
  • 18
2

Ah, I just found the answer to my own question. It's not standard functionality and you basically have to roll your own: https://github.com/tailrecursion/boot/blob/master/Makefile#L21

d11wtq
  • 34,788
  • 19
  • 120
  • 195
  • 1
    Yes, i was about to answer that, they basically append the content of the jar at the the end of the bash script and launch that with java -jar. The java launcher ignores the script content and start loading the jar where it starts, really nice. – uraimo Mar 09 '15 at 13:19