Getting rJava/JRI to work (It is painful!)

First you can download the the tar file from http://www.rforge.net/rJava/files/. I used the rJava_0.8-5.tar.gz. Then I unzip the file to my desktop. You can find two sample files under ~/Desktop/rJava/jri/examples. Currently, I just need jri.

When you run the test file in Eclipse, you might get error:

  • Cannot find JRI native library

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

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

Use this command:

  • sudo cp ~/Desktop/rJava/jri/libjri.so  /usr/lib

Another error coming: “cannot find system Renviron”.

For this error, you have several solutions:

  • set up “environment” in Eclipse per file under “Run Configuration…” (works, not productive)
  • set up system environment variables (works for whole Eclipse)
  • create a script to pass the information (not pass my test yet)

Reference:

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

How to Install Sun Java on Ubuntu 10.04 LTS

Follow command lines:

  • sudo add-apt-repository “deb http://archive.canonical.com/ lucid partner” (Ubuntu official website provides these packages now)
  • sudo apt-get update
  • sudo apt-get install sun-java6-bin sun-java6-jre sun-java6-plugin
  • sudo apt-get install sun-java6-jdk

If you already have openjdk installed, you might need extra steps to setup the default java

  • update-java-alternatives -l (list all available java)

for example, in my computer, I have both openjdk and sun:

java-6-openjdk 1061 /usr/lib/jvm/java-6-openjdk
java-6-sun 63 /usr/lib/jvm/java-6-sun

set the default jdk to sun java

  • sudo update-java-alternatives -s java-6-sun

Reference:http://www.clickonf5.org/linux/how-install-sun-java-ubuntu-1004-lts/7777