O'Reilly logo

Clojure Programming Cookbook by Nicolas Modrzyk, Makoto Hashimoto

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Calling Scala from Clojure

In this recipe, we will integrate Clojure and Scala. We will configure a mixing project using Leiningen.

Getting ready

We create a project by lein new clojure-scala and project.clj as follows:

(defproject clojure-scala "0.1.0-SNAPSHOT" 
  :description "FIXME: write description" 
  :url "http://example.com/FIXME" 
  :license {:name "Eclipse Public License" 
            :url "http://www.eclipse.org/legal/epl-v10.html"} 
  :dependencies [[org.clojure/clojure "1.8.0"] 
                 [org.scala-lang/scala-library "2.11.7"]] 
  :plugins [[io.tomw/lein-scalac "0.1.2"]] 
  :scala-source-path "src/scala" 
  :scala-version "2.11.7" 
  :prep-tasks ["scalac"] 
  :main clojure-scala.core 
  ) 

After modifying the project.clj, start the REPL.

How to do it...

We will explain how Clojure code calls ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required