[KRX2A1]oracle@krx2adb01:/home/oracle> R CMD INSTALL rJava_0.9-4.tar.gz
* installing to library ‘/usr/lib64/R/library’
* installing *source* package ‘rJava’ ...
** package ‘rJava’ successfully unpacked and MD5 sums checked
checking for gcc... gcc -m64 -std=gnu99
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
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 : '/u01/app/oracle/product/11.2.0.3/dbhome_1/jdk/jre/bin/java'
archiver : '/u01/app/oracle/product/11.2.0.3/dbhome_1/jdk/bin/jar'
compiler : '/u01/app/oracle/product/11.2.0.3/dbhome_1/jdk/bin/javac'
header prep.: '/u01/app/oracle/product/11.2.0.3/dbhome_1/jdk/bin/javah'
cpp flags : '-I/u01/app/oracle/product/11.2.0.3/dbhome_1/jdk/include -I/u01/app/oracle/product/11.2.0.3/dbhome_1/jdk/include/linux'
java libs : '-L/u01/app/oracle/product/11.2.0.3/dbhome_1/jdk/jre/lib/amd64/server -L/u01/app/oracle/product/11.2.0.3/dbhome_1/jdk/jre/lib/amd64 -L/u01/app/oracle/product/11.2.0.3/dbhome_1/jdk/jre/../lib/amd64 -ljvm'
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 ‘/usr/lib64/R/library/rJava’
This is caused by not setting up the JAVA-related environmental parameter. Firstly, we need to set up the parameter and then execute the javareconf as follows:
[KRX2A1]oracle@krx2adb01:/home/oracle> export JAVA_HOME=/u01/app/oracle/product/11.2.0.3/dbhome_1/jdk/jre
[KRX2A1]oracle@krx2adb01:/home/oracle> R CMD javareconf -e
Java interpreter : /u01/app/oracle/product/11.2.0.3/dbhome_1/jdk/jre/bin/java
Java version : 1.5.0_30
Java home path : /u01/app/oracle/product/11.2.0.3/dbhome_1/jdk/jre
Java compiler : /u01/app/oracle/product/11.2.0.3/dbhome_1/jdk/jre/../bin/javac
Java headers gen.: /u01/app/oracle/product/11.2.0.3/dbhome_1/jdk/jre/../bin/javah
Java archive tool: /u01/app/oracle/product/11.2.0.3/dbhome_1/jdk/jre/../bin/jar
Java library path: $(JAVA_HOME)/lib/amd64/server:$(JAVA_HOME)/lib/amd64:$(JAVA_HOME)/../lib/amd64
JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server -L$(JAVA_HOME)/lib/amd64 -L$(JAVA_HOME)/../lib/amd64 -ljvm
JNI cpp flags : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/linux
The following Java variables have been exported:
JAVA_HOME JAVA JAVAC JAVAH JAR JAVA_LIBS JAVA_CPPFLAGS JAVA_LD_LIBRARY_PATH
Running: /bin/bash
Here I used the pre-installed JDK 1.5.x from Oracle Database 11g R2. If you want, you can install the latest Oracle Java 7 or 8, too.
As shown above, JAVA_HOME is exported, but due to this, the required libjvm.so library cannot be successfully loaded. Hence, before installing rJava package, we need to unset it by executing
[oracle@krx2adb01 ~]$ unset JAVA_HOME
[oracle@krx2adb01 ~]$ R CMD INSTALL rJava_0.9-4.tar.gz
Now, it works pretty well.