I have been for a while reading about this issue, at github and here at stackoverflow.
However, I don't seem to find the right fix to my problem.
Here is the process of what I did:
a while ago I started using Spark and I had a Java related error which, based on this post I solved by doing:
sudo rm /usr/bin/java
sudo ln -s /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java /usr/bin
Today, I am trying to connect to our Redshift database using:
redshift.drv <- JDBC('com.amazon.redshift.jdbc41.Driver',
'~/Amazon\ Redshift\ JDBC\ Driver/RedshiftJDBC41-1.1.10.1010.jar',
identifier.quote="'")
which throws the following error:
Error in .jfindClass(as.character(driverClass)[1]) : class not found
based on the answer at github I run:
$ R CMD javareconf
Java interpreter : /usr/bin/java
Java version : 1.8.0_66
Java home path : /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
Unable to locate an executable at "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/javac" (-1)
Java compiler : not functional
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar
System Java on OS X
trying to compile and link a JNI program
detected JNI cpp flags :
detected JNI linker flags :
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -DPLATFORM_PKGTYPE='"mac.binary.mavericks"' -fPIC -Wall -mtune=core2 -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/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
Java library path:
JNI cpp flags :
JNI linker flags :
Updating Java configuration in /Library/Frameworks/R.framework/Resources
Done.
which 1st) throws this conftest.c:1:10: fatal error: 'jni.h' file not found
error and 2nd) is not consistent with what R sees:
> J("java.lang.System")$getProperty("java.version")
[1] "1.6.0_65"
At this stage I have the "intuition" that the commands I run to be able to use Spark were not adequate, since it is clear I don't have a consistent environment.
Therefore, my question is:
Does anyone know a fix to this set up? Something that allows R to see the 1.8.0_66 version (find the 'jni.h'
file, etc...)
I really don't ming having to re-do all the Java installation, I just want to have a clean, functional environment.
in case is of any help, this driver works perfectly:
prod.drv <- JDBC('com.microsoft.sqlserver.jdbc.SQLServerDriver',
'~/sqljdbc_4.0/enu/sqljdbc4.jar',
identifier.quote="'")
Thanks!
EDIT:
I added:
setenv JAVA_HOME `/usr/libexec/java_home -v 1.8`
to my .tcshrc
file and run:
R CMD javareconf JAVA_CPPFLAGS=/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/include/jni.h
(if I don't pass the JAVA_CPPFLAGS explicitly it will not find it, obtaining the same error as before).
Now I get the following error:
Java interpreter : /Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/jre/bin/java
Java version : 1.8.0_73
Java home path : /Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home
Java compiler : /Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/bin/javac
Java headers gen.: /Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/bin/javah
Java archive tool: /Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/bin/jar
System Java on OS X
trying to compile and link a JNI program
detected JNI cpp flags: /Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/include/jni.h
detected JNI linker flags : -framework JavaVM
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG /Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/include/jni.h -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -DPLATFORM_PKGTYPE='"mac.binary.mavericks"' -fPIC -Wall -mtune=core2 -g -O2 -c conftest.c -o conftest.o
clang: error: cannot specify -o when generating multiple output files
make: *** [conftest.o] Error 1
Unable to compile a JNI program
JAVA_HOME : /Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home
Java library path:
JNI cpp flags :
JNI linker flags :
Updating Java configuration in /Library/Frameworks/R.framework/Resources
Done.
so, any help would be highly appreciated :)