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

First you can download the the tar file from 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 “” 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/  /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)


  3. Script:

How to Install Sun Java on Ubuntu 10.04 LTS

Follow command lines:

  • sudo add-apt-repository “deb 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