title: RJDBC issues: Error in .jfindClass(as.character(driverClass)[1]) : class not found
body: <p>I have been for a while reading about this issue, <a href="https://github.com/s-u/rJava/issues/47" rel="nofollow noreferrer">at github</a> and here at <a href="https://stackoverflow.com/questions/30738974/rjava-load-error-in-rstudio-r-after-upgrading-to-osx-yosemite">stackoverflow</a>. </p>
  
  <p>However, I don't seem to find the right fix to my problem. </p>
  
  <p>Here is the process of what I did: </p>
  
  <p>a while ago I started using Spark and I had a Java related error which, based on <a href="https://stackoverflow.com/questions/12757558/installed-java-7-on-mac-os-x-but-terminal-is-still-using-version-6/14875241#14875241">this post</a> I solved by doing: </p>
  
  <pre><code>sudo rm /usr/bin/java
  sudo ln -s /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java /usr/bin
  </code></pre>
  
  <p>Today, I am trying to connect to our Redshift database using: </p>
  
  <pre><code>redshift.drv &lt;- JDBC('com.amazon.redshift.jdbc41.Driver',
                   '~/Amazon\ Redshift\ JDBC\ Driver/RedshiftJDBC41-1.1.10.1010.jar',
                  identifier.quote="'")
  </code></pre>
  
  <p>which throws the following error:</p>
  
  <pre><code>Error in .jfindClass(as.character(driverClass)[1]) : class not found
  </code></pre>
  
  <p>based on the answer at <a href="https://github.com/s-u/rJava/issues/47" rel="nofollow noreferrer">github</a> I run:</p>
  
  <pre><code>$ 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 &lt;jni.h&gt;
       ^
  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.
  </code></pre>
  
  <p>which 1st) throws this <code>conftest.c:1:10: fatal error: 'jni.h' file not found</code> error and 2nd) is not consistent with what R sees: </p>
  
  <pre><code>&gt; J("java.lang.System")$getProperty("java.version")
  [1] "1.6.0_65"
  </code></pre>
  
  <p>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. </p>
  
  <p>Therefore, my question is:</p>
  
  <p><strong>Does anyone know a fix to this set up? Something that allows R to see the 1.8.0_66 version (find the <code>'jni.h'</code> file, etc...)</strong> </p>
  
  <p>I really don't ming having to re-do all the Java installation, I just want to have a clean, functional environment. </p>
  
  <p>in case is of any help, this driver works perfectly:</p>
  
  <pre><code>prod.drv &lt;- JDBC('com.microsoft.sqlserver.jdbc.SQLServerDriver',
               '~/sqljdbc_4.0/enu/sqljdbc4.jar',
               identifier.quote="'")
  </code></pre>
  
  <p>Thanks!</p>
  
  <p><strong>EDIT:</strong> </p>
  
  <p>I added: </p>
  
  <pre><code>setenv JAVA_HOME `/usr/libexec/java_home -v 1.8`
  </code></pre>
  
  <p>to my <code>.tcshrc</code> file and run: </p>
  
  <pre><code>R CMD javareconf JAVA_CPPFLAGS=/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/include/jni.h
  </code></pre>
  
  <p>(if I don't pass the JAVA_CPPFLAGS explicitly it will not find it, obtaining the same error as before). </p>
  
  <p>Now I get the following error: </p>
  
  <pre><code>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.
  </code></pre>
  
  <p>so, any help would be highly appreciated :)</p>