waheebyaqub
waheebyaqub

Reputation: 293

Why RJava cannot be installed

I am trying to install RJava but I couldn't. Here are the file and outputs I think can be used for troubleshooting the error. I checked similar questions but my error is different from other questions posted

Here is the output of error, Some redundant lines have been removed

install.packages("rJava")
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 whether Java interpreter works... checking whether JNI programs can be compiled... yes
checking whether JNI programs can be run... yes
checking JNI data types... ok
checking whether Rinterface.h exports R_CStackXXX variables... yes
checking whether Rinterface.h exports R_SignalHandlers... yes
configure: creating ./config.status
config.status: creating src/Makefile
config.status: creating Makefile
config.status: creating run
config.status: creating src/config.h
** libs
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I. -I/usr/lib/jvm/java-6-openjdk-   amd64/jre/../include     -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c Rglue.c -o Rglue.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I. -I/usr/lib/jvm/java-6-openjdk-amd64/jre/../include     -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c arrayc.c -o arrayc.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I. -I/usr/lib/jvm/java-6-openjdk-amd64/jre/../include     -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c callJNI.c -o callJNI.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I. -I/usr/lib/jvm/java-6-openjdk-amd64/jre/../include     -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c callback.c -o callback.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I. -I/usr/lib/jvm/java-6-openjdk-amd64/jre/../include     -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c fields.c -o fields.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I. -I/usr/lib/jvm/java-6-openjdk-amd64/jre/../include     -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c init.c -o init.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I. -I/usr/lib/jvm/java-6-openjdk-amd64/jre/../include     -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c jri_glue.c -o jri_glue.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I. -I/usr/lib/jvm/java-6-openjdk-amd64/jre/../include     -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c loader.c -o loader.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I. -I/usr/lib/jvm/java-6-openjdk-amd64/jre/../include     -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c otables.c -o otables.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I. -I/usr/lib/jvm/java-6-openjdk-amd64/jre/../include     -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c rJava.c -o rJava.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I. -I/usr/lib/jvm/java-6-openjdk-amd64/jre/../include     -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c tools.c -o tools.o
gcc -std=gnu99 -shared -Wl,-Bsymbolic-functions -Wl,-z,relro -o rJava.so Rglue.o arrayc.o callJNI.o callback.o fields.o init.o jri_glue.o loader.o otables.o rJava.o tools.o -L/usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64/server -ljvm -L/usr/lib/R/lib -lR
(cd ../jri && make)
make[1]: Entering directory `/tmp/RtmpyveV0g/R.INSTALL38bc46246ade/rJava/jri`
make -C src JRI.jar
make[2]: Entering directory `/tmp/RtmpyveV0g/R.INSTALL38bc46246ade/rJava/jri/src`
/usr/bin/javac -target 1.4 -source 1.4 -d . ../Mutex.java ../RBool.java    ../RConsoleOutputStream.java ../REXP.java ../RFactor.java ../RList.java ../RMainLoopCallbacks.java ../RVector.java ../Rengine.java ../package-info.java
warning: [options] bootstrap class path not set in conjunction with -source 1.4
warning: [options] source value 1.4 is obsolete and will be removed in a future release
warning: [options] target value 1.4 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
 4 warnings
/usr/bin/javah -d . -classpath . org.rosuda.JRI.Rengine
gcc -std=gnu99 -c -o Rengine.o Rengine.c -g -Iinclude  -DRIF_HAS_CSTACK -DRIF_HAS_RSIGHAND -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -I/usr/lib/jvm/java-6-openjdk-amd64/jre/../include  -fpic -I/usr/lib/jvm/java-6-openjdk-amd64/jre/../include -I/usr/share/R/include -I/usr/share/R/include
gcc -std=gnu99 -c -o jri.o jri.c -g -Iinclude  -DRIF_HAS_CSTACK -DRIF_HAS_RSIGHAND -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -I/usr/lib/jvm/java-6-openjdk-amd64/jre/../include  -fpic -I/usr/lib/jvm/java-6-openjdk-amd64/jre/../include -I/usr/share/R/include -I/usr/share/R/include
gcc -std=gnu99 -c -o Rcallbacks.o Rcallbacks.c -g -Iinclude  -DRIF_HAS_CSTACK -DRIF_HAS_RSIGHAND -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -I/usr/lib/jvm/java-6-openjdk-amd64/jre/../include  -fpic -I/usr/lib/jvm/java-6-openjdk-amd64/jre/../include -I/usr/share/R/include -I/usr/share/R/include
gcc -std=gnu99 -c -o Rinit.o Rinit.c -g -Iinclude  -DRIF_HAS_CSTACK -DRIF_HAS_RSIGHAND -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -I/usr/lib/jvm/java-6-openjdk-amd64/jre/../include  -fpic -I/usr/share/R/include -I/usr/share/R/include
gcc -std=gnu99 -c -o globals.o globals.c -g -Iinclude  -DRIF_HAS_CSTACK -DRIF_HAS_RSIGHAND -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -I/usr/lib/jvm/java-6-openjdk-amd64/jre/../include  -fpic -I/usr/lib/jvm/java-6-openjdk-amd64/jre/../include
gcc -std=gnu99 -c -o rjava.o rjava.c -g -Iinclude  -DRIF_HAS_CSTACK -DRIF_HAS_RSIGHAND -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -I/usr/lib/jvm/java-6-openjdk-amd64/jre/../include  -fpic -I/usr/lib/jvm/java-6-openjdk-amd64/jre/../include
rjava.c: In function ‘RJava_init_ctrl’:
rjava.c:51:8: warning: ignoring return value of ‘write’, declared with attribute   warn_unused_result [-Wunused-result]
rjava.c:52:7: warning: ignoring return value of ‘read’, declared with attribute   warn_unused_result [-Wunused-result]
rjava.c: In function ‘RJava_request_callback’:
rjava.c:39:8: warning: ignoring return value of ‘write’, declared with attribute  warn_unused_result [-Wunused-result]
rjava.c: In function ‘RJava_clear_lock’:
rjava.c:30:8: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
rjava.c: In function ‘RJava_request_lock’:
rjava.c:22:8: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
gcc -std=gnu99 -o libjri.so Rengine.o jri.o Rcallbacks.o Rinit.o globals.o rjava.o  -shared -L/usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64/server -ljvm -Wl,--export-dynamic -fopenmp  -L/usr/lib/R/lib -lR -lpcre -llzma -lbz2 -lrt -ldl -lm
/usr/bin/javac -target 1.4 -source 1.4 -d . ../Mutex.java ../RBool.java  ../RConsoleOutputStream.java ../REXP.java ../RFactor.java ../RList.java  ../RMainLoopCallbacks.java ../RVector.java ../Rengine.java ../package-info.java
warning: [options] bootstrap class path not set in conjunction with -source 1.4
warning: [options] source value 1.4 is obsolete and will be removed in a future release
warning: [options] target value 1.4 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
4 warnings
/usr/bin/jar fc JRI.jar org libjri.so
make[2]: Leaving directory `/tmp/RtmpyveV0g/R.INSTALL38bc46246ade/rJava/jri/src`
rm -f libjri.so
cp src/libjri.so libjri.so
/usr/bin/javac -target 1.4 -source 1.4 -classpath src/JRI.jar -d examples    examples/rtest.java
warning: [options] bootstrap class path not set in conjunction with -source 1.4
warning: [options] source value 1.4 is obsolete and will be removed in a future release
warning: [options] target value 1.4 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
Note: examples/rtest.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
4 warnings
/usr/bin/javac -target 1.4 -source 1.4 -classpath src/JRI.jar -d examples     examples/rtest2.java
warning: [options] bootstrap class path not set in conjunction with -source 1.4
warning: [options] source value 1.4 is obsolete and will be removed in a future release
warning: [options] target value 1.4 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
Note: examples/rtest2.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
4 warnings
make[1]: Leaving directory `/tmp/RtmpyveV0g/R.INSTALL38bc46246ade/rJava/jri`
installing via 'install.libs.R' to /home/waheeb/R/x86_64-pc-linux-gnu-library/3.1/rJava
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/home/waheeb/R/x86_64-pc-linux-gnu-library /3.1/rJava/libs/rJava.so':
libjvm.so: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/waheeb/R/x86_64-pc-linux-gnu-library/3.1/rJava’
Warning in install.packages :
installation of package ‘rJava’ had non-zero exit status

This is the Java alternative in my system:

*0            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java    1061      auto mode.   
1            /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java    1061      manual mode.   
2            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java    1051      manual mode.   
3            /usr/local/java/jdk1.8.0/bin/java                 1         manual mode.   

and here is the /etc/R/ldpaths file: Just showing two lines.

  ${JAVA_HOME=/usr/lib/jvm/java-6-openjdk/jre}.  
 :${R_JAVA_LD_LIBRARY_PATH=${JAVA_HOME}/lib/amd64/server}

here is the location of libjvm.so file:

/usr/local/java/jdk1.8.0/jre/lib/amd64/server/libjvm.so

Any help is appreciated

Upvotes: 2

Views: 2784

Answers (2)

BlipBertMon
BlipBertMon

Reputation: 1

Some folks have to install from source, for whatever reason.

In the case of building from source, R CMD build ... seems to be looking for the Lempel-Ziv library liblzma

liblzma.*.dylib doesn't appear natively distributed at least not on my OSX/10.8.4 ;

I just happened to have an liblzma.5.dylib sitting around
from I don't know where, which after 

export LDFLAGS='-L/path/to../../' # liblzma.*.dylib

./configure

R CMD build (of affected CRAN pkg, e.g. JGR rJava ... ) completes.

From what is the liblzma.dylib dependency supposed to be derived from ??

There appear multiple possible sources: XZ (http://macpkg.sourceforge.net/), etc.

Upvotes: 0

Dirk is no longer here
Dirk is no longer here

Reputation: 368439

Did you try

sudo apt-get install r-cran-rjava 

yet?

We do maintain a package so that you don't have to fight the configuration by hand.

Upvotes: 5

Related Questions