-
Notifications
You must be signed in to change notification settings - Fork 11
Home
Clj is a Clojure REPL and package management system. It’s designed to complement the project-oriented approach of dependency management systems like Leiningen and Maven, both of which are my preferred tools for managing traditional-project dependencies. However, much of what I use Clojure for, including Incanter-based data analysis, is not really project-oriented. In these cases, it is more convenient to have access to a REPL (and Swank server) backed by a global package-management system.
Another goal of the clj project is to improve the out-of-box experience for Clojure. There are many approaches to helping people get started with Clojure, from the streamlined starter-pack called Dejour, which only includes Clojure and Clojure-contrib, to the full-monty approach of labrepl, which includes several additional Clojure libraries, instructions for configuring every available Clojure IDE plugin, and web-based Clojure tutorials.
Clj takes a third approach by providing an easy to launch REPL combined with the ability to easily search for and install Clojure packages from the Clojars repository.
Clj uses Leiningen to manage the packages in the .clj repository, and there is a project.clj file in the .clj directory that can be customized by hand if desired.
Install
- Download http://incanter.org/downloads/clj.jar
- Run
java -jar clj.jar self-install
(note: your browser may have added a .zip extension to the jar during download) - Copy
~/.clj/bin/clj(.bat)
to your path
Try it out
- Run
clj list
to see what packages are installed. - Run
clj search compojure
to search for Compojure on Clojars. - Run
clj describe compojure
to get a description of the latest version of compojure. - Run
clj install compojure
to install the latest version of compojure. - Run
clj repl
orclj swingrepl
to launch a REPL configured for all the installed packages.
Usage: clj command [arguments]
Available commands
-
repl
: Starts a Clojure repl. -
swingrepl
: Starts a Clojure swingrepl. -
swank [port]
: Start a local swank server on port 4005 (or as specified). -
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 byclj clean
andclj reload
to actually remove packages from the repository. -
clean
: Removes all packages from~/.clj/lib
directory. -
reload
: Reloads all packages listed byclj list
. -
classpath
: Prints classpath. -
add-classpath dirs-or-jarfiles
: Adds directories or jar files to the classpath. Directories should have a trailing / to distinguish them from jar files. -
add-jars jar file(s)
: Copies jar files to the clj repository. Directories should have a trailing / to distinguish them from jar files." -
remove-classpath dir-or-jarfile
: Removes a directory or jar file from the classpath. Remember to include trailing / for directories.
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.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.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.
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.