Search code examples
rrjava

Install rJava on centOS


I have a problem installing rJava on a centOS VM (cloudera cdh3u4).

I did this first: sudo R CMD javareconf

[cloudera@localhost ~]$ sudo R CMD javareconf
Java interpreter : /usr/bin/java
Java version     : 1.6.0_31
Java home path   : /usr/java/jdk1.6.0_31/jre
Java compiler    : /usr/bin/javac
Java headers gen.:
Java archive tool: /usr/bin/jar
Java library path: $(JAVA_HOME)/lib/amd64/server:$(JAVA_HOME)/lib/amd64:$(JAVA_HOME)/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server -L$(JAVA_HOME)/lib/amd64 -L$(JAVA_HOME)/../lib/amd64 -L/usr/java/packages/lib/amd64 -L/usr/lib64 -L/lib64 -L/lib -L/usr/lib -ljvm
JNI cpp flags    : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/linux

Updating Java configuration in /usr/lib64/R
Done.

But I get this out when I'd like to install rJava:

> install.packages( c('rJava'),
+ repos='http://cran.revolutionanalytics.com')

    ...
    configure: error: One or more Java configuration variables are not set.
    Make sure R is configured with full Java support (including JDK). Run
    R CMD javareconf
    as root to add Java support to R.

    If you don't have root privileges, run
    R CMD javareconf -e
    to set all Java-related variables and then install rJava.

    ERROR: configuration failed for package ‘rJava’
    * removing ‘/home/cloudera/R/x86_64-redhat-linux-gnu-library/2.15/rJava’

    The downloaded source packages are in
            ‘/tmp/RtmpR5V6t5/downloaded_packages’
    Warning message:
    In install.packages(c("rJava"), repos = "http://cran.revolutionanalytics.com") :
      installation of package ‘rJava’ had non-zero exit status

I'm not sure but does it mean that I need to install JDK? If yes, do you know a good site where I find a step-by-step info to install the right JDK for my case? (My final purpose is to install rhdfs and rjava is a needed dependency for that)


Solution

  • Yes you do need the JDK.

    For what it is worth, my Debian / Ubuntu package installs openjdk-6-jdk when building our r-cran-rjava package.

    And it looks like the java-1.6.0-openjdk.x86_64 package should work for you, you can also try java-1.7.0-openjdk.x86_64.