正确链接/安装rJava(Ubuntu / RStudio)

时间:2018-01-17 09:07:11

标签: r rjava

我无法在Ubuntu 14.04上安装rJava for RStudio 1.0.143。我尝试了this questionthis questionthis question等等,但事实上我现在很困惑,因为我无法做出头或尾。

最后,我想安装https://github.com/tomwenseleers/export。因此,我首先要安装

install.packages("rJava")

结尾
> install.packages("rJava")
Installing package into ‘/home/ben/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/rJava_0.9-9.tar.gz'
Content type 'application/x-gzip' length 660454 bytes (644 KB)
==================================================
downloaded 644 KB

* 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    : '/usr/bin/jar'
compiler    : '/usr/bin/javac'
header prep.: '/usr/bin/javah'
cpp flags   : '-I/usr/lib/jvm/java-9-oracle/include -I/usr/lib/jvm/java-9-oracle/include/linux'
java libs   : '-L/usr/lib/jvm/java-9-oracle/lib/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... ok
checking whether JRI should be compiled (autodetect)... yes
checking whether debugging output should be enabled... no
checking whether memory profiling is desired... no
checking whether threads support is requested... no
checking whether callbacks support is requested... no
checking whether JNI cache support is requested... no
checking whether headless init is enabled... no
checking whether JRI is requested... yes
configure: creating ./config.status
config.status: creating src/Makevars
config.status: creating R/zzz.R
config.status: creating src/config.h
=== configuring in jri (/tmp/RtmpOmEePT/R.INSTALL155372402b38/rJava/jri)
configure: running /bin/bash ./configure --disable-option-checking '--prefix=/usr/local'  --cache-file=/dev/null --srcdir=.
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
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 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-9-oracle/include -I/usr/lib/jvm/java-9-oracle/include/linux     -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -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-9-oracle/include -I/usr/lib/jvm/java-9-oracle/include/linux     -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -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-9-oracle/include -I/usr/lib/jvm/java-9-oracle/include/linux     -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -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-9-oracle/include -I/usr/lib/jvm/java-9-oracle/include/linux     -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -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-9-oracle/include -I/usr/lib/jvm/java-9-oracle/include/linux     -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -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-9-oracle/include -I/usr/lib/jvm/java-9-oracle/include/linux     -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -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-9-oracle/include -I/usr/lib/jvm/java-9-oracle/include/linux     -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -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-9-oracle/include -I/usr/lib/jvm/java-9-oracle/include/linux     -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -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-9-oracle/include -I/usr/lib/jvm/java-9-oracle/include/linux     -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -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-9-oracle/include -I/usr/lib/jvm/java-9-oracle/include/linux     -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -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-9-oracle/include -I/usr/lib/jvm/java-9-oracle/include/linux     -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c tools.c -o tools.o
gcc -std=gnu99 -shared -L/usr/lib/R/lib -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-9-oracle/lib/server -ljvm -L/usr/lib/R/lib -lR
(cd ../jri && make)
make[1]: Entering directory `/tmp/RtmpOmEePT/R.INSTALL155372402b38/rJava/jri'
make -C src JRI.jar
make[2]: Entering directory `/tmp/RtmpOmEePT/R.INSTALL155372402b38/rJava/jri/src'
/usr/bin/javac -target 1.6 -source 1.6 -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.6
warning: [options] source value 1.6 is obsolete and will be removed in a future release
warning: [options] target value 1.6 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
4 warnings
/usr/bin/javah -d . -classpath . org.rosuda.JRI.Rengine

Warning: The javah tool is planned to be removed in the next major
JDK release. The tool has been superseded by the '-h' option added
to javac in JDK 8. Users are recommended to migrate to using the
javac '-h' option; see the javac man page for more information.

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 -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -I/usr/lib/jvm/java-9-oracle/include -I/usr/lib/jvm/java-9-oracle/include/linux  -fpic -I/usr/lib/jvm/java-9-oracle/include -I/usr/lib/jvm/java-9-oracle/include/linux -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 -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -I/usr/lib/jvm/java-9-oracle/include -I/usr/lib/jvm/java-9-oracle/include/linux  -fpic -I/usr/lib/jvm/java-9-oracle/include -I/usr/lib/jvm/java-9-oracle/include/linux -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 -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -I/usr/lib/jvm/java-9-oracle/include -I/usr/lib/jvm/java-9-oracle/include/linux  -fpic -I/usr/lib/jvm/java-9-oracle/include -I/usr/lib/jvm/java-9-oracle/include/linux -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 -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -I/usr/lib/jvm/java-9-oracle/include -I/usr/lib/jvm/java-9-oracle/include/linux  -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 -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -I/usr/lib/jvm/java-9-oracle/include -I/usr/lib/jvm/java-9-oracle/include/linux  -fpic -I/usr/lib/jvm/java-9-oracle/include -I/usr/lib/jvm/java-9-oracle/include/linux
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 -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -I/usr/lib/jvm/java-9-oracle/include -I/usr/lib/jvm/java-9-oracle/include/linux  -fpic -I/usr/lib/jvm/java-9-oracle/include -I/usr/lib/jvm/java-9-oracle/include/linux
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]
   write(ipcout, buf, sizeof(ptrlong));
        ^
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]
   write(ipcout, buf, sizeof(ptrlong));
        ^
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]
   write(ipcout, buf, sizeof(ptrlong) * 3);
        ^
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]
   write(ipcout, buf, sizeof(ptrlong));
        ^
rjava.c:52:7: warning: ignoring return value of ‘read’, declared with attribute warn_unused_result [-Wunused-result]
   read(resin, buf, sizeof(ptrlong) * 2);
       ^
gcc -std=gnu99 -o libjri.so Rengine.o jri.o Rcallbacks.o Rinit.o globals.o rjava.o  -shared -L/usr/lib/jvm/java-9-oracle/lib/server -ljvm -Wl,--export-dynamic -fopenmp -Wl,-Bsymbolic-functions -Wl,-z,relro -L/usr/lib/R/lib -lR -lpcre -llzma -lbz2 -lz -lrt -ldl -lm
/usr/bin/javac -target 1.6 -source 1.6 -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.6
warning: [options] source value 1.6 is obsolete and will be removed in a future release
warning: [options] target value 1.6 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
4 warnings
/usr/bin/jar fc JRI.jar org libjri.so
make[2]: Leaving directory `/tmp/RtmpOmEePT/R.INSTALL155372402b38/rJava/jri/src'
rm -f libjri.so
cp src/libjri.so libjri.so
/usr/bin/javac -target 1.6 -source 1.6 -classpath src/JRI.jar -d examples examples/rtest.java
warning: [options] bootstrap class path not set in conjunction with -source 1.6
warning: [options] source value 1.6 is obsolete and will be removed in a future release
warning: [options] target value 1.6 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.6 -source 1.6 -classpath src/JRI.jar -d examples examples/rtest2.java
warning: [options] bootstrap class path not set in conjunction with -source 1.6
warning: [options] source value 1.6 is obsolete and will be removed in a future release
warning: [options] target value 1.6 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/RtmpOmEePT/R.INSTALL155372402b38/rJava/jri'
installing via 'install.libs.R' to /home/ben/R/x86_64-pc-linux-gnu-library/3.4/rJava
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error: package or namespace load failed for ‘rJava’:
 .onLoad failed in loadNamespace() for 'rJava', details:
  call: dyn.load(file, DLLpath = DLLpath, ...)
  error: unable to load shared object '/home/ben/R/x86_64-pc-linux-gnu-library/3.4/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/ben/R/x86_64-pc-linux-gnu-library/3.4/rJava’
Warning in install.packages :
  installation of package ‘rJava’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/Rtmp8FVXzD/downloaded_packages’

我该怎么办?

进一步的信息:

R:

> Sys.getenv('JAVA')
[1] ""

终端:

ben@Ben-PC:~$ java -version
java version "9.0.1"
Java(TM) SE Runtime Environment (build 9.0.1+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)

ben@Ben-PC:~$ whereis java
java: /usr/bin/java /etc/java /usr/bin/X11/java /usr/share/java

ben@Ben-PC:~$ sudo apt-get install openjdk-9-jdk
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'oracle-java9-installer' instead of 'openjdk-9-jdk'
oracle-java9-installer is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

ben@Ben-PC:~$ sudo R CMD javareconf
*** JAVA_HOME is not a valid path, ignoring
Java interpreter : /usr/bin/java
Java version     : 9.0.1
Java home path   : /usr/lib/jvm/java-9-oracle
Java compiler    : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar

trying to compile and link a JNI program 
detected JNI cpp flags    : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
detected JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/usr/lib/jvm/java-9-oracle/include -I/usr/lib/jvm/java-9-oracle/include/linux     -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c conftest.c -o conftest.o
gcc -std=gnu99 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o conftest.so conftest.o -L/usr/lib/jvm/java-9-oracle/lib/server -ljvm -L/usr/lib/R/lib -lR


JAVA_HOME        : /usr/lib/jvm/java-9-oracle
Java library path: $(JAVA_HOME)/lib/server
JNI cpp flags    : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
Updating Java configuration in /usr/lib/R
Done.

ben@Ben-PC:~$ sudo apt-get install r-cran-rjava
Reading package lists... Done
Building dependency tree       
Reading state information... Done
r-cran-rjava is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

0 个答案:

没有答案