You can start using Dunaj just like any other Clojure library, but with a small exception. As Dunaj is a fork of Clojure, you must exclude original Clojure from your dependency tree.

A library-only variant called Dunaj lite is available for cases where custom Clojure forks are not an option. The set of features provided by Dunaj lite are nearly identical to ones offered by Dunaj. Dunaj lite is also more backwards compatible and uses less dependencies.

Dunaj tries hard to be backwards compatible with existing Clojure libraries. As Dunaj introduces qualified special symbols, some problems may arise in libraries that perform code analysis or eval code in other namespaces.

Dunaj requires Oracle JDK 8. Also note that so far Dunaj has only been tested under Linux.

Using Boot

While Dunaj lite can be used as any other Clojure library, Dunaj requires boot 2.1.3 or higher.

To use Dunaj correctly, your project must set BOOT_CLOJURE_NAME and BOOT_CLOJURE_VERSION environment variables to Dunaj’s Clojure fork. The recommended way is to do it through a custom boot.properties file. Look at this example file.

After that, include following dependency in your build.boot file:

[org.dunaj/dunaj "0.7.0"]

You also need to exclude any Clojure dependency, e.g. with:

(set-env! :exclusions '[org.clojure/clojure])

Using Leiningen

To start using Dunaj, include following dependency in your leiningen project:

[org.dunaj/dunaj "0.7.0"]

Use leiningen’s :exclusions to exclude any Clojure dependency:

[com.example/foo "1.2.3" :exclusions [org.clojure/clojure]]

You can also start using Dunaj with a dunaj-starter leiningen project. Clone starter repository with git clone https://github.com/dunaj-project/dunaj-starter.git

REPL

After starting REPL (e.g. with lein repl), eval (dunaj!) form to start working with Dunaj:

1
2
3
4
5
user=> (dunaj!)
#object[clojure.lang.Namespace 0x2fe126bf "dunaj.user"]
dunaj.user=> (println! (str (print json [1 2 3] {:a "foo"})))
[1,2,3] {"a":"foo"}
nil

Use in sources

To use Dunaj in your sources, use :api ns declaration:

1
2
3
4
5
6
7
8
9
10
11
12
13
(ns foo.bar
  (:api dunaj))

(defn bar :- String
  [s :- String]
  (str (print "Hello %s!" s)))

(defn foo :- nil
  [s :- String]
  (println! (bar s))
  nil)

(foo "World")

Standalone REPL

Other method to start Dunaj REPL is to use a standalone .jar file.

  1. Download latest standalone binary

  2. Start with java -cp dunaj-latest.jar dunaj.main

Alternatively, you can start a clojure REPL with java -cp dunaj-latest.jar clojure.main and then use (dunaj!) to switch to Dunaj.