файл jni.h не найден при установке java - PullRequest
0 голосов
/ 25 сентября 2019

Я пытаюсь установить rJava на R.Я запускаю следующий

install.packages("rJava", type = 'source')

, который имеет следующий вывод:

trying URL 'https://cran.rstudio.com/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... /usr/local/Cellar/gcc/9.2.0/bin/gcc-9
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 /usr/local/Cellar/gcc/9.2.0/bin/gcc-9 accepts -g... yes
checking for /usr/local/Cellar/gcc/9.2.0/bin/gcc-9 option to accept ISO C89... none needed
checking how to run the C preprocessor... /usr/local/Cellar/gcc/9.2.0/bin/gcc-9 -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... no
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 /usr/local/Cellar/gcc/9.2.0/bin/gcc-9 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 : '/Users/112186/.jenv/shims/java'
archiver    : '/Users/112186/.jenv/shims/jar'
compiler    : '/Users/112186/.jenv/shims/javac'
header prep.: '/Users/112186/.jenv/shims/javah'
cpp flags   : ''
java libs   : ''
configure: error: One or more Java configuration variables are not set.
Make sure R is configured with full Java support (including JDK). Run
R CMD javareconf
as root to add Java support to R.

If you don't have root privileges, run
R CMD javareconf -e
to set all Java-related variables and then install rJava.

ERROR: configuration failed for package ‘rJava’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rJava’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rJava’
Warning in install.packages :
  installation of package ‘rJava’ had non-zero exit status

The downloaded source packages are in
    ‘/private/var/folders/7_/n_pmyvxs5b56zdy5qh4gfmt8x_n_tl/T/Rtmp5snSGe/downloaded_packages’

Итак, я загрузил последнюю версию Java SE из https://www.oracle.com/technetwork/java/javase/downloads/jdk13-downloads-5672538.html. В терминале я запускаю команду: R CMD javareconf (аналогично выводу команды R CMD javareconf -e), который выплыл:

Java interpreter : /Users/112186/.jenv/shims/java
Java version     : 1.6.0_65
Java home path   : /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Java compiler    : /Users/112186/.jenv/shims/javac
Java headers gen.: /Users/112186/.jenv/shims/javah
Java archive tool: /Users/112186/.jenv/shims/jar

trying to compile and link a JNI program 
detected JNI cpp flags    : 
detected JNI linker flags : -L/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Libraries -ljvm
/usr/local/Cellar/gcc/9.2.0/bin/gcc-9 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include  -fPIC  -Wall -g -O2  -c conftest.c -o conftest.o
conftest.c:1:10: fatal error: jni.h: No such file or directory
    1 | #include <jni.h>
      |          ^~~~~~~
compilation terminated.
make: *** [conftest.o] Error 1
Unable to compile a JNI program


JAVA_HOME        : /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Java library path: 
JNI cpp flags    : 
JNI linker flags : 
Updating Java configuration in /Library/Frameworks/R.framework/Resources
Done.

Кажется, проблема в том, что sw не может найти файл jni.h.Тем не менее, я могу найти 2 таких файла на моем Mac:

/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers/jni.h
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk 1/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers/jni.h

Какой файл является правильным?Как я могу получить sw для поиска этих файлов?

Здесь вы можете найти некоторую информацию о моей Java:

PST9972:tmp 112186$ javac -version
javac 1.6.0_65
PST9972:tmp 112186$ java -version
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-468)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-468, mixed mode)
PST9972:tmp 112186$ which javac
/Users/112186/.jenv/shims/javac
PST9972:tmp 112186$ which java
/Users/112186/.jenv/shims/java
PST9972:tmp 112186$ 

Я следовал за некоторыми ответами в этой теме R CMDjavareconf не находит jni.h .но команда apt update (apt: invalid flag: update ) выдает мне ошибку.Также предложение @KevinZarca ( R: установка пакета rJava не удалась ) не работает для меня, потому что первый шаг,

sudo update-alternatives --config java. 
Password:
sudo: update-alternatives: command not found

, дает мне ошибку.Спасибо за вашу помощь.

...