开发者

java.lang.UnsatisfiedLinkError: Java cannot find my dll's?

I am developing a program that calls R functions from Java using JRI/rJava. I was coding the program in NetBeans on another machine, which was working fine (i.e. able to run the code). I have since then moved to another machine and have been running into problems.

The exac开发者_运维百科t error message I am seeing is this:

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: E:\R\R-2.13.1\library\rJava\jri\jri.dll: The specified path is invalid
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1807)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1732)
    at java.lang.Runtime.loadLibrary0(Runtime.java:823)
    at java.lang.System.loadLibrary(System.java:1028)
    at org.rosuda.JRI.Rengine.<clinit>(Rengine.java:19)
    at com.rjava.test.rtest.main(rtest.java:64)
Java Result: 1

I have read the FAQs for JRI/rJava, and have been scouring the internet for fixes, but have made no progress. Here is what I have done so far:

  • Created an environment variable called R_HOME: "E:\R\R-2.13.1"
  • Added "%R_HOME%\bin\x64" to the PATH environment variable
  • Added "%R_HOME%\library\rJava\JRI" to the PATH environment variable (this is where jri.dll is located)
  • Set the required jar files as compile time libraries (JRI.jar, JRIEngine.jar, REngine.jar) in NetBeans
  • set the following VM options in NetBeans: : -Djava.library.path=E:\R\R-2.13.1\library\rJava\jri (This is where jri.dll is located)

I have restarted my computer to make sure that the changes stick.

To make sure I configured things correctly, I ran the following in the command line:

java -cp E:\R\R-2.13.1\library\rJava\jri\JRI.jar;E:\R\R-2.13.1\library\rJava\jri\examples rtest

And the example java files ran fine. I'm beginning to think my new machine just hates me.


The message indicates that it the path E:\R\R-2.13.1\library\rJava\jri\jri.dll is invalid. Are you sure that path exists? Also, is E a mapped drive that is mapped to a path that has spaces in it? I'm not sure if the spaces are the issue, but it eliminates one issue. I would try just putting the dll in C:\ or somewhere very simple and seeing if it can find it there as a simple test.

Also verify that the -Djava.library.path is being passed as you think it is (you can check that with visualvm or jconsole).


You could try this:

-Djava.library.path=E:\R\R-2.13.1\library\rJava\jri -cp E:\R\R-2.13.1\library
\rJava\jri;E:\R\R-2.13.1\library\rJava\jri\JRI.jar;E:\R\R-2.13.1
\library\rJava\jri\examples

The reason I say this is that, perhaps the .dll also needs to be in the classpath as well as the library path in order for the classloader to load it? Its probably not true, but worth trying. Also is "rJava" correct? Other than that, it looks to me like your doing it right.


To locate JRI installed with rJava, use system.file("jri",package="rJava") in R.

set that path to your path (environment variables in windows), restart your netbeans. and try to run your program again

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜