Skip to content
liebke edited this page Sep 14, 2010 · 30 revisions

Quick start

clj is a Clojure REPL and package management system.

Install

  1. Download http://incanter.org/downloads/clj-1.0.0-SNAPSHOT-standalone.jar
  2. Run java -jar clj-1.0.0-SNAPSHOT-standalone.jar self-install
  3. Copy ~/.clj/bin/clj(.bat) to your path

Try it out

  1. Run clj list to see what packages are installed.
  2. Run clj search compojure to search for Compojure on Clojars.
  3. Run clj describe compojure to get a description of the latest version of compojure.
  4. Run clj install compojure to install the latest version of compojure.
  5. Run clj repl or clj swingrepl to launch a REPL configured for all the installed packages.

Documentation

Usage: clj command [arguments]

Available commands

  • repl: Starts a Clojure repl.
  • swingrepl: Starts a Clojure swingrepl.
  • run filename: Runs the given Clojure file.
  • list: Prints a list of installed packages.
  • search term: Prints a list of packages on clojars.org with names that contain the given search term.
  • install package-name [package-version]: Installs the given package from clojars.org, defaulting to the inferred latest version.
  • describe package-name [package-version]: Prints the description of the given package as found in the description field of its pom file.
  • versions package-name: Prints a list of the versions of the given package available on clojars.org
  • remove package-name: Removes given package from the clj-repo package list, must be followed by clj clean and clj reload to actually remove packages from the repository.
  • clean: Removes all packages from ~/.clj/lib directory.
  • reload: Reloads all packages listed by clj list.
  • add-classpath classpath: Adds classpath to ~/.clj/bin/clj(.bat) files.
  • remove-classpath classpath: Removes classpath from ~/.clj/bin/clj(.bat) files.

Packages are installed in $HOME/.clj/lib, and can be used by applications other than clj
by including the jars in the directory on the classpath. For instance, to start a command line
REPL with jline, run the following command:

java -cp ~/.clj/lib/'*' jline.ConsoleRunner clojure.main

Installation
Download the clj.jar file (or follow the instructions below to build from source):

wget http://incanter.org/downloads/clj-1.0.0-SNAPSHOT-standalone.jar

and either double-click on the jar file to run self-install, or run the self-install command from the command line:

java -jar clj-1.0.0-SNAPSHOT-standalone.jar self-install

Self-install will

  • create a $HOME/.clj directory
  • initialize a local reposistory for Clojure packages in $HOME/.clj/lib
  • create the shell and Windows batch scripts,
    • $HOME/.clj/bin/clj
    • $HOME/.clj/bin/clj.bat

Alternative installation directories
You can provide alternative CLJ_HOME and USER_HOME directories by passing them as properties to the above java command.

For instance, the following command creates the .clj and Maven .m2 directories under C:\ on a Windows box (something I had to do since Windows had problems with my shared home under VMWare, \\vmware-host\…).

java -Duser.home=C:\ -jar clj-1.0.0-SNAPSHOT-standalone.jar self-install

clj scripts
Once installation is complete, you should either add $HOME/.clj/bin to your path, export PATH=~/.clj/bin:$PATH on Unix/Mac OS X, or move the platform-appropriate clj script to a directory on your path.

Build instructions

lein deps
lein uberjar
java -jar clj-1.0.0-SNAPSHOT-standalone.jar self-install

Copyright © 2010 David Edgar Liebke

Distributed under the Eclipse Public License, the same as Clojure.

Clone this wiki locally