Database Reference
In-Depth Information
7.
Unfortunately, the JLink library, which we just installed, expects to be called from
within the Mathematica directory tree, not from within the Maven repository directory.
In order to make it happy, we'll need to go into the local Maven repository, remove the
installed JAR ile, and add a symbolic link to the original one:
$ cd ~/.m2/repository/local/repo/JLink/9.0/
$ rm JLink-9.0.jar
remove JLink-9.0.jar? y
$ ln -s \
/Applications/Mathematica.app/SystemFiles/Links/JLink/JLink.jar
\
JLink-9.0.jar
8.
We can now include the JLink library in our project.clj ile, as shown here:
:dependencies [[org.clojure/clojure "1.66.0"]
[local.repo/JLink "9.0"]]
9.
We can import the libraries we've just installed and deine a few utility functions that
we'll need to run whenever we want to interface with Mathematica:
(use 'clojuratica)
(import [com.wolfram.jlink MathLinkFactory])
(defn init-mma [mma-command]
(defonce math-evaluate
(math-evaluator
(doto
(MathLinkFactory/createKernelLink mma-command)
(.discardAnswer)))))
(init-mma
(str "-linkmode launch -linkname "
" /Applications/Mathematica.app/Contents/MacOS/MathKernel "))
(def-math-macro math math-evaluate)
Notice that the call to init-mma includes the full path to MathKernel (I've highlighted this.).
This will change depending on your system. For example, under Linux, the program will be /
usr/local/Wolfram/Mathematica/9.0/Executables/math . Substitute the path and
name of the executable so that it works on your system.
 
Search WWH ::




Custom Search