简体   繁体   English

RJDBC问题:.jfindClass(as.character(driverClass)[1])中的错误:找不到类

[英]RJDBC issues: Error in .jfindClass(as.character(driverClass)[1]) : class not found

I have been for a while reading about this issue, at github and here at stackoverflow . 我已经在github和这里的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: 不久前,我开始使用Spark,遇到一个与Java相关的错误,根据这篇文章,我通过执行以下操作解决了错误:

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数据库:

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: 根据我在github上的答案运行:

$ 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: 第一个)抛出此conftest.c:1:10: fatal error: 'jni.h' file not found错误,第二个)与R看到的不一致:

> 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. 在这个阶段,我有一个直觉,就是我运行的能够使用Spark的命令还不够,因为很明显我没有一个一致的环境。

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...) 允许R看到1.8.0_66版本的东西(找到'jni.h'文件,等等...)

I really don't ming having to re-do all the Java installation, I just want to have a clean, functional environment. 我真的不需要重新安装所有Java,我只想拥有一个干净的功能环境。

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: 到我的.tcshrc文件并运行:

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). (如果我没有显式传递JAVA_CPPFLAGS,它将找不到它,并获得与以前相同的错误)。

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 :) 因此,任何帮助将不胜感激:)

I had the same issue of 我有同样的问题

Error in .jfindClass(as.character(driverClass)[1]) : class not found

and couldn't find a way to get it working. 并且找不到使它工作的方法。 I used the RPostgreSQL library to solve it, using this answer: https://stackoverflow.com/a/30855566/1686839 我使用RPostgreSQL库来解决它,使用以下答案: https ://stackoverflow.com/a/30855566/1686839

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM