Search code examples
javamacos-mojave

MacOS does not recognize updated Java on MacOS 10.14.6


In the process of re-installing packages after updating R to 3.6.1 via Homebrew, I encountered this problem (running within RStudio 1.2.5019):

install.packages( "rJava" )
...
...
...
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 ‘/usr/local/lib/R/3.6/site-library/rJava’

Running

bash-3.2$ sudo R CMD javareconf

yields

Java interpreter : /usr/bin/java
Java version     : 1.8.0_25
Java home path   : /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre
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/darwin
detected JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
clang -I"/usr/local/Cellar/r/3.6.1_1/lib/R/include" -DNDEBUG -I/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/../include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/../include/darwin  -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
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/Cellar/r/3.6.1_1/lib/R/lib -L/usr/local/opt/gettext/lib -L/usr/local/opt/readline/lib -L/usr/local/lib -o conftest.so conftest.o -L/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/server -ljvm -L/usr/local/Cellar/r/3.6.1_1/lib/R/lib -lR -lintl -Wl,-framework -Wl,CoreFoundation


JAVA_HOME        : /Library/Java/JavaVirtualMachines/jdk1.8.0_25.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 /usr/local/Cellar/r/3.6.1_1/lib/R
Done.

Re running install.packages( "rJava" ) yields a slightly different error message:


*** 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 ‘/usr/local/lib/R/3.6/site-library/rJava’
Warning in install.packages :
  installation of package ‘rJava’ had non-zero exit status

But I noticed that the output of R CMD javareconf lists an old Java version: 1.8.0_25. Running java -version confirms:

java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

Running /usr/libexec/java_home -V confirms that only 1.8.0_25 is installed (even after having downloaded and run the installer for the latest Java version):

Matching Java Virtual Machines (1):
    1.8.0_25, x86_64:   "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home

/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home

Looking at the Java Control Panel shows that 1.8.0_231-b11 is supposedly installed.

I have tried uninstalling Java and re-installing Java to no effect.

Why the discrepancy? How do I get they OS to recognize the most current version?

I'm running MacOS Mojave 10.14.6

Thanks,


Solution

  • OK, newbie error. I was installing the JRE and not the JDK. Downloading the JDK from Oracle and installing solved the java version problem.