[R] Installing R in Linux: problems with JAVA packages (rJava, RWeka, ...) ?

Martyn Plummer plummer at iarc.fr
Wed Oct 22 17:28:00 CEST 2008


Well this is interesting. I have a working java setup (using OpenJDK).
But I can break it by running "R CMD javareconf -e". This command
exports a number of JAVA_* environment variables. The rJava configure
script uses these instead of querying R, but the compilation then fails.

It seems that the crucial difference is that the environment variables
JAVA_CPPFLAGS and JAVA_LIBS contain references to JAVA_HOME that are not
expanded.  With the non-working configuration I get this output from the
configure script:

cpp flags   : '-I$(JAVA_HOME)/../include -I
$(JAVA_HOME)/../include/linux'
java libs   : '-L$(JAVA_HOME)/lib/amd64/server -L$(JAVA_HOME)/lib/amd64
-L$(JAVA_HOME)/../lib/amd64 -L -L/usr/java/packages/lib/amd64
-L/usr/lib64 -L/lib64 -L/lib -L/usr/lib -ljvm'

Whereas with the working R configuration I get the fully expanded
version:

cpp flags   :
'-I/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/../include
-I/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/../include/linux'
java libs   :
'-L/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/amd64/server
-L/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/amd64
-L/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/../lib/amd64 -L
-L/usr/java/packages/lib/amd64 -L/usr/lib64 -L/lib64 -L/lib -L/usr/lib
-ljvm'

Try compiling in a new shell without exporting any of these JAVA_*
variables.

Martyn

On Wed, 2008-10-22 at 12:00 +0100, Paulo Cortez wrote:
> Thanks for the many answers I received.
> 
> This is becoming a nightmare and I am concluding that installing java1.6 
> in CentOS5 is particularly hard, specially if you installed previous jdk 
> versions...
> 
> I tryed a wide range of solutions. I resume some of them:
> 
> 1) Tryed to reinstall jdk1.6 and use update-alternatives command;
> 1) The CentOS5 howto java guide is outdated and does not work 
> (http://wiki.centos.org/HowTos/JavaOnCentOS);
> 2) I installed openjdk, from: http://openjdk.java.net/install/
> I checked if the java was updated with:
> $alternatives --config java
> 
> There are 2 programs which provide 'java'.
> 
>    Selection    Command
> -----------------------------------------------
>     1           /usr/lib/jvm/jre-1.4.2-gcj/bin/java
> *+ 2           /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
> 
> Then, after several R CMD javareconf attemps I got:
> 
> ------
> Java interpreter : /usr/bin/java
> Java version     : 1.6.0_0
> Java home path   : /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre
> Java compiler    : /usr/bin/javac
> Java headers gen.: /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/../bin/javah
> Java archive tool: /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/../bin/jar
> Java library path: 
> $(JAVA_HOME)/lib/i386/server:$(JAVA_HOME)/lib/i386:$(JAVA_HOME)/../lib/i386::/usr/java/packages/lib/i386:/lib:/usr/lib
> JNI linker flags : -L$(JAVA_HOME)/lib/i386/server 
> -L$(JAVA_HOME)/lib/i386 -L$(JAVA_HOME)/../lib/i386 -L 
> -L/usr/java/packages/lib/i386 -L/lib -L/usr/lib -ljvm
> JNI cpp flags    : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/linux
> 
> Updating Java configuration in /usr/lib/R
> Done.
> ------
> The link files are ok:
> $ ls -la /usr/bin/ja*
> lrwxrwxrwx 1 root root  8 Apr 11  2008 /usr/bin/jade -> openjade
> lrwxrwxrwx 1 root root 48 Oct 22 10:52 /usr/bin/java -> 
> /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/bin/java
> lrwxrwxrwx 1 root root 49 Oct 22 10:52 /usr/bin/javac -> 
> /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/bin/javac
> lrwxrwxrwx 1 root root 51 Oct 22 11:19 /usr/bin/javadoc -> 
> /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/bin/javadoc
> lrwxrwxrwx 1 root root 49 Oct 22 11:18 /usr/bin/javah -> 
> /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/bin/javah
> lrwxrwxrwx 1 root root 50 Oct 22 10:52 /usr/bin/javaws -> 
> /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/bin/javaws
> 
> But then I try:
> $ R CMD INSTALL rJava (the rJava.tar.gz was unpacked)
> ...
> checking whether JNI programs can be compiled... configure: error: 
> Cannot compile a simple JNI program. See config.log for details.
> ---------
> Opening the config.log file I get:
> ---------
> configure:3880: checking whether JNI programs can be compiled
> configure:3898: gcc -o conftest -O3 -g -std=gnu99 
> -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/linux   conftest.c 
> -L$(JAVA_HOME)/lib/i386/server -L$(JAVA_HOME)/l
> ib/i386 -L$(JAVA_HOME)/../lib/i386 -L -L/usr/java/packages/lib/i386 
> -L/lib -L/usr/lib -ljvm >&5
> /usr/bin/ld: cannot find -ljvm
> collect2: ld returned 1 exit status
> configure:3904: $? = 1
> configure: failed program was:
> |
> | #include <jni.h>
> | int main(void) {
> |     jobject o;
> |     JNI_CreateJavaVM(0, 0, 0);
> |     return 0;
> | }
> |
> configure:3920: error: Cannot compile a simple JNI program. See 
> config.log for details.
> 
> All these attempts took 2 hours of my life, with no results :(((
> 
> Regards,

-----------------------------------------------------------------------
This message and its attachments are strictly confidenti...{{dropped:8}}



More information about the R-help mailing list