0

I'm trying to install 'rJava' package on my RStudio. But it gives me this error:

configure: error: one or more Java tools are missing.

*** JDK is incomplete! Please make sure you have a complete JDK. JRE is *not* sufficient.
configure: error: ./configure failed for jri
ERROR: configuration failed for package ‘rJava’
* removing ‘/Users/art/Library/R/3.4/library/rJava’
* restoring previous ‘/Users/art/Library/R/3.4/library/rJava’
Warning in install.packages :
  installation of package ‘rJava’ had non-zero exit status

When I try to install on R, it gives me:

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.
ERROR: configuration failed for package ‘rJava’
* removing ‘/Users/art/Library/R/3.4/library/rJava’
* restoring previous ‘/Users/art/Library/R/3.4/library/rJava’

An old solution : sudo R CMD javareconf used to work for me but not any more.

This is what it gives:

Java interpreter : /usr/bin/java
Java version     : 1.8.0_252
Java home path   : /Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre
Java compiler    : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar
Non-system Java on macOS

trying to compile and link a JNI program 
detected JNI cpp flags    : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/darwin
detected JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre/../include -I/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre/../include/darwin  -I/usr/local/include   -fPIC  -Wall -g -O2  -c conftest.c -o conftest.o
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o conftest.so conftest.o -L/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre/lib/server -ljvm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation


JAVA_HOME        : /Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre
Java library path: $(JAVA_HOME)/lib/server
JNI cpp flags    : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/darwin
JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
Updating Java configuration in /Library/Frameworks/R.framework/Resources
Done.

java -version gives:

openjdk version "1.8.0_252"
OpenJDK Runtime Environment (Zulu 8.46.0.20-SA-macosx) (build 1.8.0_252-b14)
OpenJDK 64-Bit Server VM (Zulu 8.46.0.20-SA-macosx) (build 25.252-b14, mixed mode)

My system is MacOS Mojave 10.14.6, could anyone please help me with this issue? Thank you!

Arthur
  • 398
  • 6
  • 20

1 Answers1

-1

Your JAVA_HOME is pointing to JRE folder. You need to set it to JDK folder.
You can use /usr/libexec/java_home -v <version you want> to get the path you need for JAVA_HOME. For instance, to get the path to the 1.7 JDK you can run /usr/libexec/java_home -v 1.7 and it will return the path to the JDK. In your .profile or .bash_profile just add export JAVA_HOME=/usr/libexec/java_home -v <version> and you should be good.
Do javac -version if you want to check JDK installation.

Ankit
  • 682
  • 1
  • 6
  • 14
  • `/usr/libexec/java_home -v 1.8` gives me `/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home`. I opened `.bash_profile` and added `export JAVA_HOME=/usr/libexec/java_home -v 1.8` but it didn't work. I also tried changing it to `export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home`. It didn't work either. `javac -version` returns `Unable to locate an executable at "/usr/libexec/java_home/bin/javac" (-1)` – Arthur May 12 '20 at 18:46
  • I changed it to `export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home` and `javac -version` gives `javac 1.8.0_252`. Unfortunately, I tried to install `rJava` in both R and RStudio. They gave the same error as op. – Arthur May 12 '20 at 18:56
  • Download JAVA 8 from [Oracle](https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html) and then set the path for JAVA_HOME in `.bashrc`. – Ankit May 12 '20 at 19:04
  • Umm, I didnt find a way to set path in `.bashrc` – Arthur May 12 '20 at 20:13
  • Did you download the Oracle JDK 8? Setting path in `.bashrc` file is simply pasting the `export JAVA_HOME=` in the file – Ankit May 12 '20 at 20:24
  • Check [this](https://stackoverflow.com/questions/55648312/mac-os-x-mojave-set-environment-variable-permanently) out for setting environment variables on your system. – Ankit May 12 '20 at 20:47