2017-07-26 60 views
0

试图让RJDBC在Rstudio中工作,我无法获得任何工作。我试过重新安装rJava和堆栈溢出提供的其他解决方案,但没有任何工作。当使用java JDK 1.8时R无法找到java主页 - rJava不会工作

首先,错误运行L ibrary(RJDBC)然后driver <- JDBC("com.amazon.redshift.jdbc42.Driver", "~/RedshiftJDBC42-1.2.1.1001.jar", identifier.quote="“)`

给出了错误

JavaVM: requested Java version ((null)) not available. Using Java at "" instead. JavaVM: Failed to load JVM: /bundle/Libraries/libserver.dylib JavaVM FATAL: Failed to load the jvm library. Error in .jinit(classPath) : JNI_GetCreatedJavaVMs returned -1

通过一些解决方案,对SO like this one

推荐阅读我n EED运行sudo R CMD javareconf其中规定:

Java interpreter : /usr/bin/java 
Java version  : 1.8.0_141 
Java home path : /Library/Java/JavaVirtualMachines/jdk1.8.0_141.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/Users/rubinsjx/anaconda/lib/R/include -DNDEBUG -I/Library/Java/JavaVirtualMachines/jdk1.8.0_141.jdk/Contents/Home/jre/../include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_141.jdk/Contents/Home/jre/../include/darwin -I/Users/rubinsjx/anaconda/include -fPIC -I/Users/rubinsjx/anaconda/include -c conftest.c -o conftest.o 
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Users/rubinsjx/anaconda/lib/R/lib -arch x86_64 -L/Users/rubinsjx/anaconda/lib -lgfortran -L/Users/rubinsjx/anaconda -o conftest.so conftest.o -L/Library/Java/JavaVirtualMachines/jdk1.8.0_141.jdk/Contents/Home/jre/lib/server -ljvm -L/Users/rubinsjx/anaconda/lib/R/lib -lR -lintl -liconv -lc -Wl,-framework -Wl,CoreFoundation 


JAVA_HOME  : /Library/Java/JavaVirtualMachines/jdk1.8.0_141.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 
LNGRDUM-4171620:etc rubinsjx$ Java library path: $(JAVA_HOME)/lib/server 
-bash: JAVA_HOME: command not found 
Error: Could not find or load main class library 
LNGRDUM-4171620:etc rubinsjx$ JNI cpp flags : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/darwin 
-bash: JAVA_HOME: command not found 
-bash: JAVA_HOME: command not found 
-bash: JNI: command not found 

运行没有关于-n

Java interpreter : /usr/bin/java 
Java version  : 1.8.0_141 
Java home path : /Library/Java/JavaVirtualMachines/jdk1.8.0_141.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/Users/rubinsjx/anaconda/lib/R/include -DNDEBUG -I/Library/Java/JavaVirtualMachines/jdk1.8.0_141.jdk/Contents/Home/jre/../include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_141.jdk/Contents/Home/jre/../include/darwin -I/Users/rubinsjx/anaconda/include -fPIC -I/Users/rubinsjx/anaconda/include -c conftest.c -o conftest.o 
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Users/rubinsjx/anaconda/lib/R/lib -arch x86_64 -L/Users/rubinsjx/anaconda/lib -lgfortran -L/Users/rubinsjx/anaconda -o conftest.so conftest.o -L/Library/Java/JavaVirtualMachines/jdk1.8.0_141.jdk/Contents/Home/jre/lib/server -ljvm -L/Users/rubinsjx/anaconda/lib/R/lib -lR -lintl -liconv -lc -Wl,-framework -Wl,CoreFoundation 


JAVA_HOME  : /Library/Java/JavaVirtualMachines/jdk1.8.0_141.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 /Users/rubinsjx/anaconda/lib/R 
Done. 

一个奇怪的是,我没有使用蟒蛇运行R.所以我不知道如果多数民众赞成造成问题与否。

如果我再尝试重新安装rJava

> install.packages("rJava", type = "source") 
Installing package into ‘/Users/rubinsjx/Library/R/3.3/library’ 
(as ‘lib’ is unspecified) 
trying URL 'https://cran.rstudio.com/src/contrib/rJava_0.9-8.tar.gz' 
Content type 'application/x-gzip' length 656615 bytes (641 KB) 
================================================== 
downloaded 641 KB 

* installing *source* package ‘rJava’ ... 
** package ‘rJava’ successfully unpacked and MD5 sums checked 
checking for gcc... clang 
checking whether the C compiler works... yes 
checking for C compiler default output file name... a.out 
checking for suffix of executables... 
checking whether we are cross compiling... no 
checking for suffix of object files... o 
checking whether we are using the GNU C compiler... yes 
checking whether clang accepts -g... yes 
checking for clang option to accept ISO C89... none needed 
checking how to run the C preprocessor... clang -E 
checking for grep that handles long lines and -e... /usr/bin/grep 
checking for egrep... /usr/bin/grep -E 
checking for ANSI C header files... 
rm: conftest.dSYM: is a directory 
rm: conftest.dSYM: is a directory 
yes 
checking for sys/wait.h that is POSIX.1 compatible... yes 
checking for sys/types.h... yes 
checking for sys/stat.h... yes 
checking for stdlib.h... yes 
checking for string.h... yes 
checking for memory.h... yes 
checking for strings.h... yes 
checking for inttypes.h... yes 
checking for stdint.h... yes 
checking for unistd.h... yes 
checking for string.h... (cached) yes 
checking sys/time.h usability... yes 
checking sys/time.h presence... yes 
checking for sys/time.h... yes 
checking for unistd.h... (cached) yes 
checking for an ANSI C-conforming const... yes 
checking whether time.h and sys/time.h may both be included... yes 
configure: checking whether clang supports static inline... 
yes 
checking whether setjmp.h is POSIX.1 compatible... yes 
checking whether sigsetjmp is declared... yes 
checking whether siglongjmp is declared... yes 
checking Java support in R... present: 
interpreter : '/usr/bin/java' 
archiver : '/usr/bin/jar' 
compiler : '/usr/bin/javac' 
header prep.: '/usr/bin/javah' 
cpp flags : '-I/System/Library/Frameworks/JavaVM.framework/Headers' 
java libs : '-framework JavaVM' 
checking whether Java run-time works... yes 
checking whether -Xrs is supported... yes 
checking whether JNI programs can be compiled... 
configure: error: Cannot compile a simple JNI program. See config.log for details. 

Make sure you have Java Development Kit installed and correctly registered in R. 
If in doubt, re-run "R CMD javareconf" as root. 

ERROR: configuration failed for package ‘rJava’ 
* removing ‘/Users/rubinsjx/Library/R/3.3/library/rJava’ 
* restoring previous ‘/Users/rubinsjx/Library/R/3.3/library/rJava’ 
Warning in install.packages : 
    installation of package ‘rJava’ had non-zero exit status 

The downloaded source packages are in 
    ‘/private/var/folders/m2/qhhvggzd52gfff3xbvv7jlcwh_y23d/T/RtmpySEOWn/downloaded_packages’ 
> library(RJDBC) 
Loading required package: DBI 
Loading required package: rJava 
> driver <- JDBC("com.amazon.redshift.jdbc42.Driver", "~/RedshiftJDBC42-1.2.1.1001.jar", identifier.quote="`") 
JavaVM: requested Java version ((null)) not available. Using Java at "" instead. 
Error in .jinit(classPath) : JNI_GetCreatedJavaVMs returned -1 
JavaVM: Failed to load JVM: /bundle/Libraries/libserver.dylib 
JavaVM FATAL: Failed to load the jvm library. 

这是严重的驾驶我坚果。我只想将R连接到Redshift并让我活下去!

回答