Dejour provides an easy, works out of the box experience for the Clojure programming language. Clojure is a JVM-hosted, functional, general-purpose LISP variant that is especially adept at concurrent programming. You can find the clojure source and original downloads at http://clojure.org.
Unfortunately, while clojure.org provides the superb Clojure language as well as clojure-contrib (a set of useful libraries) there are a few things missing. The most important missing bit is a script that will run Clojure. Also missing is the very useful JLine providing a more robust interactive clojure interpreter or REPL.
The Dejour project pulls all of this together in a single easy to get, easy to install download. Dejour currently works on Linux, Macs, and Windows.
Step one is to download the latest Dejour tar or zip from:
Step two is to unpack Dejour. You will end up with a directory with a name like
dejour-1.1.0. Inside that directory is a bin directory, containing a Linux/Mac script, clj as well as a couple of Windows executables. If you are running on Linux or a Mac, you can run clojure by running the clj script. If you are on windows you have a choice of clj.exe which will run clojure with a console or cljw.exe which will run clojure without a console.
Step three is probably to put the dejour
bin directory on your your path.
Step four There is no step four.
If you just want the clojure REPL (i.e. interactive shell), simply run the clj script (or clj.exe on Windows):
$ clj Clojure 1.1.0 user=>
If you want to execute a file full of clojure code, call out the file after clj:
If you want to pass arguments to your clojure script, just hang them on the end of the command:
clj my-clojure-code.clj some arguments
If you need to pass a -D or -X argument to java, put it before the clojure file:
clj -Xmx500M -DFoo=bar my-clojure-code.clj some arguments
If you have other java VM arguments, you can pass them in via the -J option:
clj -J -d32
Dejour also comes with some simple examples of Clojure code from my “Clojure, the least you need to know” talk. You will find these in the examples subdirectory.
Using the clj script
If you run the script with no parameters, clj will bring up the interactive clojure ‘interpreter’: You can simply type in clojure code and immediately see the results. Alternatively, if you supply clj with the name of a clojure script, it will run that script.
The clj script and executable are designed to be very simple for beginners to use, but they are also capable of doing more elaborate things. Here are the arguments that clj understands:
-debugJust print out the java command and exit.
-no-jlineDon’t use jline
-no-contribDon’t use clojure-contrib
-cp <jar or directory>Add the next argument to the classpath
-classpath <jar or directory>Add the next argument to the classpath
-Dname=valueDefine the given Java system property, passed directly to java.
-Xjava-optionPassed directly to Java
-clientUse the java client VM
-serverUse the java server VM
-hotspotTurn on java hotspot
-Jjava-option Pass the next argument directly to java.
--(That’s two dashes) Treat everything that follows as a clojure argument
Dejour is also location independant. It will run out of wherever you decide to unpack it — no environment variables required. The only external dependancy that Dejour has is on Java: It assumes that there is a java command in your path, or that JAVA_HOME is set. If you have both, JAVA_HOME wins.
Dejour was created by Russ Olsen and is, of course, based on Clojure, clojure-contrib and JLine. Much of the clj script was hamelessly stolen from the Jruby startup script, jruby.sh. Also borrowed some code from Mark Reid’s clj script. Thanks to Fogus for some help with the README file.
See my website at russolsen.com
Copyright © 2010 Russ Olsen and released under the Apache 2.0 license.