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 : http://rforge.net/JRI/files/, and when I try running test program for JRI, I get this following error :

“cannot find JRI native library”

You need to copy the “libjri.so” 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 “libjri.so” located then copy to java.library.path :

  • $ locate libR.so
  • /usr/local/lib/R/site-library/rJava/jri/libjri.so
  • $sudo cp /usr/local/lib/R/site-library/rJava/jri/libjri.so /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 :

Reference:

  1. https://autofei.wordpress.com/2010/08/
  2. https://help.ubuntu.com/community/EnvironmentVariables
  3. http://sonivis.org/wiki/index.php/Installation_GNU_R
  4. Script: http://sonivis.org/startupEclipse
  5. http://sonivis.org/wiki/index.php/Troubleshooting#cannot_find_system_Renviron
  6. http://blog.pingoured.fr/index.php?post/2009/03/23/Getting-rJava/JRI-to-work%3A

 

 

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s