2014-04-19 244 views
-1

無法在ubuntu上安裝rjava軟件包,R版本是3.1。 jdk i.7已安裝。請分享R的java配置的確切路徑。我已經嘗試使用javareconf -e來設置rjava的env。無法安裝rJava

下面是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. 
+0

任何配置就成爲該錯誤信息提示,你跑的r CMD javareconf'爲根,或'[R CMD javareconf作爲-e'不是root然後再試一次? – josliber

+0

你把'javareconf'作爲'root'運行了嗎? –

回答

6

我已經回答了這裏之前這個問題 - 只是做

sudo apt-get install r-cran-rjava 

,因爲這是分佈中時保持包。

如果失敗了,請讓我知道,最好通過一個合適的(Debian)錯誤報告,因爲我碰巧是R包和這個rJava插件的維護者。

0

在anaconda上,您可以安裝r-java軟件包。我發現這是唯一一個爲ububtu工作的渠道。

conda install -c edurand r-rjava

0

就我而言,我測試過,創造新環境(只有R基本和rstudio),並使用R聲道R-rjava失敗。取而代之的是,康達鍛通道版本沒有javarefconf或需要

conda install -c conda-forge r-rjava