Java R Interface (JRI) Setup

天大地大妈咪最大 提交于 2019-11-28 08:48:50

Try to copy all dll files(*.dll) which in R directory to JAVA_PATH/bin. After that load the the jri native lib like:

//Right under your R class
   static {
    System.loadLibrary("jri");      
   }

I had the same problem and solved it by this method.

Thx

After reading a lot of posts and trying a lot of different solutions, it is finally working. I'm using Windows 7 64bits and I'll list the steps that I did to make it work properly.

  1. Install package rJava using R install.packages("rJava")
  2. Right-click on My Computer > Properties > Advanced System Settings > Environment Variables...
  3. Find Var PATH or CLASSPATH and Edit, add the following paths: C:\Program Files\R\R-3.4.0\bin\x64;C:\Users\ [User Name]\Documents\R\win-library\3.4\rJava\jri\x64
  4. Go to C:\Program Files\R\R-3.4.0\bin\x64 and copy all .dll files (here they are: R.dll,Rblas.dll,Rgraphapp.dll,Riconv.dll,Rlapack.dll)
  5. Past them at C:\Program Files\Java\jdk1.8.0_144\bin
  6. When you create your java project, remeber to add the JRI.jar, JRIEngine.jar and Rengine.jar to your project build path. They are located at C:\Users\ [User name]\Documents\R\win-library\3.4\rJava\jri
  7. After doing all this, I was still getting an error, that was solved when I went to C:\Users\ [User Name]\Documents\R\win-library\3.4\rJava\jri\x64 and copy the jri.dll and past inside my Java Project, like the following image:

Here is a code example and its output:

This example was retrieved from: http://codophile.com/2015/04/15/how-to-integrate-r-with-java-using-rjava/

Here's another option: add the directories of rJava and R where the dlls reside into the PATH variable, either at the Computer level or in an ant script like this for example (x64 for 64 bit installs, i386 for 32 bit, depending on your local installation):

<java fork="true" classname="${run.class}">
  <env key="PATH" path="C:/Users/myuser/Documents/R/win-library/3.0/rJava/jri/x64;C:/Program Files/R/R-3.0.2/bin/x64"/>
  <classpath>
     <path refid="run.test.classpath"/>
  </classpath>
</java>
greenish

Fellows, after few days of trying and failing I figured out my ultimate solution like:

  • the following files must be copied to directory C:/Program Files/RapidMiner/RapidMiner Studio/jre/bin/:

    • jri.dll from C:/Users/Public/Documents/Documentos/R/win-library/3.0/rJava/jri/x64/
    • all files from C:/Program Files/R/R-3.0.3/bin/x64/
  • so on RM Studio Tools tab Preferences option, Start-up tab, after checking Initialize extensions the Extensions directory must be C:\Program Files\RapidMiner\RapidMiner Studio\jre\bin\R.exe and on R tab Native lib must be C:\Program Files\RapidMiner\RapidMiner Studio\jre\bin\jri.dll

Easy, isn't it? Thank you all for the advices.

I got same issue. Resolved by add R bin to path(my OS is x64).

path=C:\Program Files\R\R-3.2.2\bin\x64

Anyway, you can find out which dll is the dependent one by use this tool http://dependencywalker.com/

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!