无法在centos R中安装rJava

时间:2014-07-08 05:08:58

标签: java r bash hdfs rjava

我无法在centos R中安装rJava,它是安装rhdfs的基础。请帮忙看看我在安装rJava时得到的输出。

> install.packages( c("rJava"))
Installing package into ‘/home/training/R/x86_64-redhat-linux-gnu-library/3.1’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
trying URL 'http://ftp.iitm.ac.in/cran/src/contrib/rJava_0.9-6.tar.gz'
Content type 'application/x-gzip' length 567515 bytes (554 Kb)
opened URL
==================================================
downloaded 554 Kb

* installing *source* package ‘rJava’ ...
** package ‘rJava’ successfully unpacked and MD5 sums checked
checking for gcc... gcc -m64 -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 -m64 -std=gnu99 accepts -g... yes
checking for gcc -m64 -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -m64 -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 -m64 -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    : '/usr/bin/jar'
compiler    : '/usr/bin/javac'
header prep.: '/usr/bin/javah'
cpp flags   : '-I/usr/java/jdk1.6.0_31/jre/../include -I/usr/java/jdk1.6.0_31/jre/../include/linux'
java libs   : '-L/usr/java/jdk1.6.0_31/jre/lib/amd64/server -ljvm'
checking whether Java run-time works... yes
checking whether -Xrs is supported... yes
checking whether JNI programs can be compiled... yes
checking JNI data types... configure: error: One or more JNI types differ from the corresponding native type. You may need to use non-standard compiler flags or a different compiler in order to fix this.
ERROR: configuration failed for package ‘rJava’
* removing ‘/home/training/R/x86_64-redhat-linux-gnu-library/3.1/rJava’

The downloaded source packages are in
    ‘/tmp/Rtmp1RKjkQ/downloaded_packages’
Warning message:
In install.packages(c("rJava")) :
  installation of package ‘rJava’ had non-zero exit status

请在下面找到我从R CMD javareconf -ed获得的内容,它显示了我在bash.profile文件中给出的正确路径。请让我知道如何安装rJava然后安装rhdfs ..

$ R CMD javareconf -ed
Java interpreter : /etc/alternatives/java_sdk_openjdk/jre/bin/java
Java version     : 1.6.0_30
Java home path   : /etc/alternatives/java_sdk_openjdk
Java compiler    : /etc/alternatives/java_sdk_openjdk/bin/javac
Java headers gen.: /etc/alternatives/java_sdk_openjdk/bin/javah
Java archive tool: /etc/alternatives/java_sdk_openjdk/bin/jar

trying to compile and link a JNI progam 
detected JNI cpp flags    : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
detected JNI linker flags : -L/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/amd64/server -ljvm
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I/etc/alternatives/java_sdk_openjdk/include -I/etc/alternatives/java_sdk_openjdk/include/linux -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic  -c conftest.c -o conftest.o
gcc -m64 -std=gnu99 -shared -L/usr/local/lib64 -o conftest.so conftest.o -L/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/amd64/server -ljvm -L/usr/lib64/R/lib -lR


JAVA_HOME        : /etc/alternatives/java_sdk_openjdk
Java library path: /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/amd64/server
JNI cpp flags    : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
JNI linker flags : -L/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/amd64/server -ljvm
Updating Java configuration in /usr/lib64/R
/usr/lib64/R/bin/javareconf: line 405: /usr/lib64/R/etc/Makeconf.new: Permission denied
*** cannot create /usr/lib64/R/etc/Makeconf.new
*** Please run as root if required.

我已经卸载并重新安装了R来执行此操作,仍然得到同样的错误,请帮助如何完成此操作..

1 个答案:

答案 0 :(得分:5)

以下说明解决了这个问题:

$export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.55.x86_64/jre
$export PATH=$PATH:$JAVA_HOME/bin
$sudo /usr/bin/R CMD javareconf
$R

这很好用,我可以在centos上安装rhdfs。