Getting JRI works for R and Java

First, I would like to thanks to Fei for the very useful tutorial,

I try several times to setup the environment, and try some configuration to get JRI works with Java. then I faced exactly the same problem.

I already have these following environment to run the program

  • OS : Ubuntu 12.04.2
  • Java : JDK 1.7.0_21
  • R : 3.1.0

I downloaded the JRI from this site :, and when I try running test program for JRI, I get this following error :

“cannot find JRI native library”

You need to copy the “” to “java.library.path”. Use following to show the path:

in your java program :

  • System.out.println(System.getProperty(“java.library.path”));

Since I already jave rjava installed, first i find where my “” located then copy to java.library.path :

  • $ locate
  • /usr/local/lib/R/site-library/rJava/jri/
  • $sudo cp /usr/local/lib/R/site-library/rJava/jri/ /usr/lib

Another error coming:

cannot find system Renviron

For this error, this solution works for me :

  • setup the environment in Eclipse, inside Run > Run Configuration > Environment , add new env R_HOME, and the value is your R (in my case : /usr/lib/R)

Or you can try these several solutions :

  • set up system environment variables for R_HOME (works for whole Eclipse) inside ~/.bashrc
  • try this command : $ sudo chmod 644 /etc/R/Renviron

Reference :


  4. Script:




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s