来自 Clojure 的 rJava
rJava from Clojure
我正在尝试将 Clojure 中的 R 与 rJava as shown here 结合使用。我有以下内容:
(ns prototype.core
(:gen-class)
(:require [prototype.dataGraph :as dg])
(:import [org.rosuda.JRI Rengine]))
(defn -main
"Program main entry point."
[& args]
(new Rengine (into-array String ["--no-save"]) false nil)
(println "Hello."))
然后,我得到堆栈跟踪
Cannot find JRI native library! Please make sure that the JRI native
library is in a directory listed in java.library.path.
java.lang.UnsatisfiedLinkError: no jri in java.library.path
看来我没有正确指定库位置...
并且 Java 构造函数的形式为:
Rengine engine = new Rengine(new String[] { "--no-save" }, false, null);
我的project.clj文件:
(defproject prototype "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"]]
:plugins [[lein-expand-resource-paths "0.0.1"]]
:resource-paths ["/usr/lib/R/site-library/rJava/jri/JRI.jar" "/usr/lib/R/site-library/rJava/jri/JRIEngine.jar" "/usr/lib/R/site-library/rJava/jri/REngine.jar"]
:main ^:skip-aot prototype.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all}})
rJava 可以成功地与 Clojure 一起使用吗?
是的,所以问题是 java.library.path 中没有正确指定共享库。这有效:
(defproject prototype "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"]]
:plugins [[lein-expand-resource-paths "0.0.1"]]
:resource-paths ["/usr/lib/R/site-library/rJava/jri/JRI.jar" "/usr/lib/R/site-library/rJava/jri/JRIEngine.jar" "/usr/lib/R/site-library/rJava/jri/REngine.jar"]
:jvm-opts [~(str "-Djava.library.path=/usr/lib/R/site-library/rJava/jri/:" (System/getenv "$LD_LIBRARY_PATH"))]
:main ^:skip-aot prototype.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all}})
我正在尝试将 Clojure 中的 R 与 rJava as shown here 结合使用。我有以下内容:
(ns prototype.core
(:gen-class)
(:require [prototype.dataGraph :as dg])
(:import [org.rosuda.JRI Rengine]))
(defn -main
"Program main entry point."
[& args]
(new Rengine (into-array String ["--no-save"]) false nil)
(println "Hello."))
然后,我得到堆栈跟踪
Cannot find JRI native library! Please make sure that the JRI native library is in a directory listed in java.library.path.
java.lang.UnsatisfiedLinkError: no jri in java.library.path
看来我没有正确指定库位置...
并且 Java 构造函数的形式为:
Rengine engine = new Rengine(new String[] { "--no-save" }, false, null);
我的project.clj文件:
(defproject prototype "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"]]
:plugins [[lein-expand-resource-paths "0.0.1"]]
:resource-paths ["/usr/lib/R/site-library/rJava/jri/JRI.jar" "/usr/lib/R/site-library/rJava/jri/JRIEngine.jar" "/usr/lib/R/site-library/rJava/jri/REngine.jar"]
:main ^:skip-aot prototype.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all}})
rJava 可以成功地与 Clojure 一起使用吗?
是的,所以问题是 java.library.path 中没有正确指定共享库。这有效:
(defproject prototype "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"]]
:plugins [[lein-expand-resource-paths "0.0.1"]]
:resource-paths ["/usr/lib/R/site-library/rJava/jri/JRI.jar" "/usr/lib/R/site-library/rJava/jri/JRIEngine.jar" "/usr/lib/R/site-library/rJava/jri/REngine.jar"]
:jvm-opts [~(str "-Djava.library.path=/usr/lib/R/site-library/rJava/jri/:" (System/getenv "$LD_LIBRARY_PATH"))]
:main ^:skip-aot prototype.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all}})