Thursday, March 10, 2011

Configuring R for Java

I have two R packages that have consistently refused to be updated: rgl (which I believe is used for 3D visualization) and rJava (an API for accessing Java from R).  I probably don't really need either one, but at least one R GUI (JGR), needs rJava.  I must have figured out (and then forgotten) the configuration magic that allows rJava to update, because the update.packages() command on my office PC (Linux Mint) has no problem with it ... but update.packages() on my laptop (also Linux Mint) kept running into an error.

So here is the solution (which I found here), just in case I need it again.
  • Run sudo update-alternatives --config java (in a terminal) and pick Sun Java as the default. (I thought I'd already done that, but apparently not.)
  • Add export JAVA_HOME=/usr/lib/jvm/java-6-openjdk/jre to .bashrc (again, thought I'd done that but hadn't).
  • Run sudo R CMD javareconf in a terminal.  (That I had done -- multiple times, with no error messages -- but apparently with the wrong configuration in place.)
  • Run R as root and update the package.
I hope that, the next time this comes up, I at least remember I put the necessary steps here.

No comments:

Post a Comment

Due to intermittent spamming, comments are being moderated. If this is your first time commenting on the blog, please read the Ground Rules for Comments. In particular, if you want to ask an operations research-related question not relevant to this post, consider asking it on Operations Research Stack Exchange.