Wednesday, January 27, 2010

Installing rSymPy on Ubuntu. JDK problem (and soln)

I've started using rSymPy, because I find myself having to being able to take derivatives and integrals again. And maybe a Computer Algebra System is something worth learning. I'm learning both Sage as well as Sympy.

Sympy has the advantage of running in pure Python. And with the recent version of Jython 2.5, it means Sympy can run on the Java Virtual Machine. And someone figured out that meant that you could call Sympy from R, using the rJava interface, using the rSymPy package

The problem is configuring R to use rJava. This can be tricky, because R has to be configured to use the Java Development Kit. Under Ubuntu, I have two machines that I had to put this on. It turns out this was easy for one machine, but difficult for the other.

The instructions are to configure R by running the following as root (or sudo)

R CMD javareconf

But then when installing rJava, I got the following error:

configure: error: One or more Java configuration variables are not set.
Make sure R is configured with full Java support (including JDK).

The problem was the JDK. When running javareconf I see:

Java home path : /usr/lib/jvm/java-6-openjdk/jre

Hmm, I thought I was using the Sun Java JDK. So I uninstall openjdk and reinstall the Sun provided JDK. After this, I run javareconf and get what I expect:

Java home path : /usr/lib/jvm/java-6-sun-1.6.0.15/jre

Now, when I use install.packages() to install rSymPy, it works.

No comments: