3

I'm trying to config R with Java and after I run sudo R CMD javareconf I get this.

sudo R CMD javareconf                                                                  12:16:29  23.11.17
Java interpreter : /usr/bin/java
Java version     : 9.0.1
Java home path   : /Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home
Java compiler    : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar
System Java on macOS

trying to compile and link a JNI program
detected JNI cpp flags    : -I/System/Library/Frameworks/JavaVM.framework/Headers
detected JNI linker flags : -framework JavaVM
clang -I/usr/local/Cellar/r/3.4.2/lib/R/include -DNDEBUG -I/System/Library/Frameworks/JavaVM.framework/Headers  -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/include   -fPIC  -g -O2  -c conftest.c -o conftest.o
conftest.c:1:10: fatal error: 'jni.h' file not found
#include <jni.h>
         ^~~~~~~
1 error generated.
make: *** [conftest.o] Error 1
Unable to compile a JNI program


JAVA_HOME        : /Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home
Java library path:
JNI cpp flags    :
JNI linker flags :
Updating Java configuration in /usr/local/Cellar/r/3.4.2/lib/R
Done.

I'm concerned by the fatal error: 'jni.h' file not found.

As a result I can install rJava.

Any idea? thanks!

lpuerto
  • 301
  • 4
  • 16
  • You did not indicate whether https://stackoverflow.com/questions/42562160/r-cmd-javareconf-not-finding-jni-h or https://github.com/Homebrew/homebrew-science/issues/3814 didn't work so others wld know what you tried to do before offering assistance. – hrbrmstr Nov 23 '17 at 11:52
  • jeeezzz!! do I have to list everything I've tried? No, none of those things worked... I tried. – lpuerto Nov 23 '17 at 12:52
  • 1
    yes, in fact, you do. you're asking others for their time, so being respectful of that is paramount since it shows you consider their time valuable and appreciate their help. hopefully others will try to overlook the entitlement issues and aid you. – hrbrmstr Nov 23 '17 at 14:46
  • I totally understand that... however, I've tried a myriad of things and none of those worked. My guess is the problem is with Java 9. – lpuerto Nov 23 '17 at 14:48

1 Answers1

0

OK !

seems that I fixed the issue reinstalling R with java

brew reinstall R --with-openblas --with-java and then I run sudo R CMD javareconf \ JAVA_CPPFLAGS='-I/System/Library/Frameworks/JavaVM.framework/Headers -I/Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/

with the following output:

/usr/local/Cellar/r/3.4.2/lib/R/bin/javareconf: line 66: -I/Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/: No such file or directory
Java interpreter : /Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home/bin/java
Java version     : 9.0.1
Java home path   : /Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home
Java compiler    : /Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home/bin/javac
Java headers gen.: /Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home/bin/javah
Java archive tool: /Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home/bin/jar
System Java on macOS

trying to compile and link a JNI program
detected JNI cpp flags    : -I/System/Library/Frameworks/JavaVM.framework/Headers
detected JNI linker flags : -framework JavaVM
clang -I/usr/local/Cellar/r/3.4.2/lib/R/include -DNDEBUG -I/System/Library/Frameworks/JavaVM.framework/Headers  -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/include   -fPIC  -I/Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home/include/darwin  -c conftest.c -o conftest.o
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/Cellar/r/3.4.2/lib/R/lib -L/usr/local/opt/openblas/lib -L/usr/local/opt/gettext/lib -L/usr/local/opt/readline/lib -L/usr/local/lib -o conftest.so conftest.o -framework JavaVM -L/usr/local/Cellar/r/3.4.2/lib/R/lib -lR -lintl -Wl,-framework -Wl,CoreFoundation


JAVA_HOME        : /Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home
Java library path:
JNI cpp flags    : -I/System/Library/Frameworks/JavaVM.framework/Headers
JNI linker flags : -framework JavaVM
Updating Java configuration in /usr/local/Cellar/r/3.4.2/lib/R
Done.

I set JAVA_HOME as:

export JAVA_HOME="$(/usr/libexec/java_home)" 

Is this correct? or is it better not define JAVA_HOME?

lpuerto
  • 301
  • 4
  • 16