web-dev-qa-db-ja.com

RJava 3.6でrJavaをUbuntu 18.04にインストールする際の問題

Ubuntu 18.04のR 3.6.1にrJavaパッケージをインストールしようとしています。同様の質問を検索しましたが、提供された回答がうまくいかなかったようです。

最初に_Sudo apt install r-cran-rjava_を試し、次にinstall.packages("rJava")を試しました

_Sudo apt install r-cran-rjava_には依存関係の問題があり、DebianBusterリポジトリを追加することで修正されたようです。 _r-cran-rjava_は正しくインストールされているように見えます。

_$ Sudo apt install r-cran-rjava
[Sudo] password for tj: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
r-cran-rjava is already the newest version (0.9-11-1cran1ppabionic0).
0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.
_

R内からinstall.packages("rJava")を実行すると、次のエラーメッセージが表示されました。

_install.packages("rJava")
Installing package into ‘/home/tj/R/x86_64-pc-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/rJava_0.9-11.tar.gz'
Content type 'application/x-gzip' length 675188 bytes (659 KB)
==================================================
downloaded 659 KB

* installing *source* package ‘rJava’ ...
** package ‘rJava’ successfully unpacked and MD5 sums checked
** using staged installation
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-11-Oracle/include -I/usr/lib/jvm/Java-11-Oracle/include/linux'
Java libs   : '-L/usr/lib/jvm/Java-11-Oracle/lib/server -ljvm'
checking whether Java run-time works... yes
checking whether -Xrs is supported... yes
checking whether -Xrs will be used... yes
checking whether JNI programs can be compiled... yes
checking whether JNI programs run... configure: error: Unable to run a simple JNI program. Make sure you have configured R with Java support (see R documentation) and check config.log for failure reason.
Warning in system(cmd) : error in running command
ERROR: configuration failed for package ‘rJava’
* removing ‘/home/tj/R/x86_64-pc-linux-gnu-library/3.6/rJava’

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

_Sudo update-alternatives --config Java_を使用してJava-11-Oracleをデフォルトに設定し、_Sudo nano /etc/environment_を使用してJava_HOMEを更新しようとしましたが、_echo $Java_HOME_では次のようになります。

_$ echo $Java_HOME
/usr/lib/jvm/Java-11-Oracle/bin/Java 
_

次に、_Sudo R CMD javareconf_と入力してRを構成しますが、機能しないようです。

_*** Java_HOME is not a valid path, ignoring
Java interpreter : /usr/bin/Java
Java version     : 11.0.4
Java home path   : /usr/lib/jvm/Java-11-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-11-Oracle/include -I/usr/lib/jvm/Java-11-Oracle/include/linux    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-uuRxut/r-base-3.6.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -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-11-Oracle/lib/server -ljvm -L/usr/lib/R/lib -lR


Java_HOME        : /usr/lib/jvm/Java-11-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.
_

install.packages("rJava")は、以前と同じエラーメッセージを返します。

私はRとUbuntuにかなり慣れていないので、他に何を試すべきか考えられません。誰かが私が間違っていることを見ることができますか?以前のバージョンのRに戻す必要がありますか?

どんな助けでも大歓迎です。

6
TJ001

あなたの端末でこれを試してください:

Sudo apt-get install -y default-jre
Sudo apt-get install -y default-jdk
Sudo R CMD javareconf

Rでこれを試した後:

install.packages("rJava")
1
Samuel Macêdo