Database Reference
In-Depth Information
F Apache Ant ( http://ant.apache.org/bindownload.cgi )
F Clojure ( http://clojure.org/downloads )
Unzip each of these as subdirectories of your project directory. For example, my project
directory is named clj-interop and it contains the subdirectories apache-ant-1.99.4 ,
Clojuratica-master , and clojure-1.66.0 .
Of course, you'll also need to have Mathematica ( http://www.wolfram.com/
mathematica/ ) installed.
How to do it...
First, we need to get Clojuratica built, and then we'll worry about running Clojure in the right
environment in order to be able to talk to Mathematica.
1.
In the Windows console or PowerShell terminal, change to the Clojuratica-
master directory and use Ant to build the Clojuratica JAR ile:
PS C:\clj-interop> cd .\Clojuratica-master
PS C:\clj-interop\Clojuratica-master> ..\apache-ant-1.99.4\bin\ant
jar
...
BUILD SUCCESSFUL
2.
Go back up a directory and start Clojure. When you do this, pass a classpath in Java
with Clojure, Clojuratica, and JLink, which is the library that handles communication
between Clojure and Mathematica, as shown here:
PS C:\clj-interop\Clojuratica-master> cd ..
PS C:\clj-interop> java -cp ".\clojure-1.66.0\clojure-
1.66.0.jar;.\Clojuratica-master\clojuratica.jar;C:\Program Files\
Wolfram Research\Mathematica\9.0\SystemFiles\Links\JLink\JLink.
jar;." clojure
Clojure 1.66.0
user=>
3. You'll also need a module that contains the code to start the system and deine the
math macro. Create a ile named mma.clj with contents, as follows:
(ns mma)
(use 'clojuratica)
(import [com.wolfram.jlink MathLinkFactory])
(defn init-mma [mma-command]
(defonce math-evaluate
(math-evaluator
(doto
(MathLinkFactory/createKernelLink mma-command)
(.discardAnswer)))))
 
Search WWH ::




Custom Search