Question

Unable to install rjava package in ubuntu, R version is 3.1. jdk i.7 installed. please share the exact path of java configuration for R. I have already tried javareconf - e to set the env for rjava.

Below is the output after rJava installation.

    install.packages("rJava")  
    Installing package into ‘/home/emraan/R/i686-pc-linux-gnu-library/3.1’  

    * installing *source* package ‘rJava’ ...  
    ** package ‘rJava’ successfully unpacked and MD5 sums checked  
    checking for gcc... gcc -std=gnu99  
    checking whether the C compiler works... yes  
    checking for C compiler default output file name... a.out  
    checking for suffix of executables...   
    checking whether we are cross compiling... no  
    checking for suffix of object files... o  
    checking whether we are using the GNU C compiler... yes  
    checking whether gcc -std=gnu99 accepts -g... yes  
    checking for gcc -std=gnu99 option to accept ISO C89... none needed  
    checking how to run the C preprocessor... gcc -std=gnu99 -E  
    checking for grep that handles long lines and -e... /bin/grep  
    checking for egrep... /bin/grep -E  
    checking for ANSI C header files... yes  
    checking for sys/wait.h that is POSIX.1 compatible... yes  
    checking for sys/types.h... yes  
    checking for sys/stat.h... yes  
    checking for stdlib.h... yes  
    checking for string.h... yes  
    checking for memory.h... yes  
    checking for strings.h... yes  
    checking for inttypes.h... yes  
    checking for stdint.h... yes  
    checking for unistd.h... yes  
    checking for string.h... (cached) yes  
    checking sys/time.h usability... yes  
    checking sys/time.h presence... yes  
    checking for sys/time.h... yes  
    checking for unistd.h... (cached) yes  
    checking for an ANSI C-conforming const... yes  
    checking whether time.h and sys/time.h may both be included... yes  
    configure: checking whether gcc -std=gnu99 supports static inline...  
    yes  
    checking whether setjmp.h is POSIX.1 compatible... yes  
    checking whether sigsetjmp is declared... yes  
    checking whether siglongjmp is declared... yes  
    checking Java support in R... present:  
    interpreter : '/usr/bin/java'  
    archiver    : ''  
    compiler    : '/usr/bin/javac'  
    header prep.: ''  
    cpp flags   : '-I/usr/lib/jvm/jdk1.7.0_51/jre/../include'  
    java libs   : '-L/usr/lib/jvm/jdk1.7.0_51/jre/lib/i386/client -ljvm'  
    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/emraan/R/i686-pc-linux-gnu-library/3.1/rJava’  
    Warning in install.packages :  
      installation of package ‘rJava’ had non-zero exit status  

    The downloaded source packages are in  
        ‘/tmp/Rtmp12bZIF/downloaded_packages’  

    **Output of sudo CMD R javareconf**

    Java interpreter : /usr/lib/jvm/jdk1.7.0_51/jre/bin/java  
    Java version     : 1.7.0_51  
    Java home path   : /usr/lib/jvm/jdk1.7.0_51/jre  
    Java compiler    : /usr/lib/jvm/jdk1.7.0_51/jre/../bin/javac  
    Java headers gen.: /usr/lib/jvm/jdk1.7.0_51/jre/../bin/javah  
    Java archive tool: /usr/lib/jvm/jdk1.7.0_51/jre/../bin/jar  

    trying to compile and link a JNI progam   
    detected JNI cpp flags    : -I$(JAVA_HOME)/../include  
    detected JNI linker flags : -L$(JAVA_HOME)/lib/i386/client -ljvm  
    gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/usr/lib/jvm/jdk1.7.0_51/jre/../include      -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c conftest.c -o conftest.o
    gcc -std=gnu99 -shared -Wl,-Bsymbolic-functions -Wl,-z,relro -o conftest.so conftest.o -L/usr/lib/jvm/jdk1.7.0_51/jre/lib/i386/client -ljvm -L/usr/lib/R/lib -lR


    JAVA_HOME        : /usr/lib/jvm/jdk1.7.0_51/jre  
    Java library path: $(JAVA_HOME)/lib/i386/client  
    JNI cpp flags    : -I$(JAVA_HOME)/../include  
    JNI linker flags : -L$(JAVA_HOME)/lib/i386/client -ljvm  
    Updating Java configuration in /usr/lib/R  
    /usr/lib/R/bin/javareconf: 405: /usr/lib/R/bin/javareconf: cannot create  /usr/lib/R/etc/Makeconf.new: Permission denied
    *** cannot create /usr/lib/R/etc/Makeconf.new
    *** Please run as root if required.  
Was it helpful?

Solution

I have answered that question here before -- just do

 sudo apt-get install r-cran-rjava

as this is a maintained package within the distribution.

If that fails, please let me know, preferably via a proper (Debian) bug report as I happen to be the maintainer of both the R package and this rJava add-on.

OTHER TIPS

On anaconda you can just install the r-java package. I found this is the only channel that worked for ububtu.

conda install -c edurand r-rjava

In my case, I've tested that creating new environment (with just r-base and rstudio) and using r channel r-rjava fails. Instead, conda-forge channel version works with no javarefconf or any configuration needed

conda install -c conda-forge r-rjava

I have the same problem and here how it works in my case:

conda install -c r r-rjava 

https://anaconda.org/r/r-rjava

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top