无法安装rJava

时间:2014-04-19 15:01:26

标签: linux r ubuntu rjava

无法在ubuntu中安装rjava包,R版本为3.1。 jdk i.7已安装。请分享R的java配置的确切路径。我已经尝试过javareconf -e来设置rjava的env。

以下是rJava安装后的输出。

    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.  

4 个答案:

答案 0 :(得分:7)

我之前在这里回答了这个问题 - 只是做了

 sudo apt-get install r-cran-rjava

因为这是分发中的维护包。

如果失败,请告诉我,最好通过正确的(Debian)错误报告,因为我碰巧是R包和这个rJava插件的维护者。

答案 1 :(得分:0)

在anaconda上,您只需安装r-java包即可。我发现这是唯一适用于ububtu的频道。

conda install -c edurand r-rjava

答案 2 :(得分:0)

就我而言,我已经测试过创建新环境(只有r-base和rstudio)并且使用r通道r-rjava失败了。相反,conda-forge通道版本不使用javarefconf或任何需要的配置

conda install -c conda-forge r-rjava

答案 3 :(得分:0)

我遇到同样的问题,在这里我的情况如何:

conda install -c r r-rjava 

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

相关问题