gpt4 book ai didi

java - 无法在 Mac OS 10.11 上加载 R xlsx 包

转载 作者:IT老高 更新时间:2023-10-28 20:45:06 25 4
gpt4 key购买 nike

我可以加载 rJava 和 xlsxjars 包,但是当我执行 library(xlsx) 时出现“加载 JVM 失败”。以下是我的详细信息。

操作系统版本:

$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.11
BuildVersion: 15A284

Java 版本:

$ java -version
java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)

Java 路径:

$ which java
/usr/bin/java

Java 主页:

$ /usr/libexec/java_home
/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home

R 版本:

$ R --version
R version 3.2.3 (2015-12-10) -- "Wooden Christmas-Tree"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin13.4.0 (64-bit)

我如何启动 R:

$ LD_LIBRARY_PATH=$(/usr/libexec/java_home)/jre/lib/server: open -a RStudio

成功加载 rJava 和 xlsxjars 包:

> library(rJava)
> library(xlsxjars)

尝试加载 xlsx 包失败:

> library(xlsx)
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 : .onLoad failed in loadNamespace() for 'xlsx', details:
call: .jinit()
error: JNI_GetCreatedJavaVMs returned -1
Error: package or namespace load failed for ‘xlsx’

R 配置:

Matts-MacBook-Pro:~ matt$ R CMD javareconf
Java interpreter : /usr/bin/java
Java version : 1.8.0_65
Java home path : /Library/Java/JavaVirtualMachines/jdk1.8.0_65.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 OS X

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/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/jre/../include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/jre/../include/darwin -I/usr/local/include -I/usr/local/include/freetype2 -I/opt/X11/include -fPIC -Wall -mtune=core2 -g -O2 -c conftest.c -o conftest.o
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o conftest.so conftest.o -L/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/jre/lib/server -ljvm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation


JAVA_HOME : /Library/Java/JavaVirtualMachines/jdk1.8.0_65.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 /Library/Frameworks/R.framework/Resources

最佳答案

不幸的是,这些符号链接(symbolic link)技巧对我没有帮助。但是,我在 stackoverflow 上发现了类似的问题。 ! (还有哪里 ;))通过执行以下操作,这对我有用:

  1. 在终端输入以下内容以正确重新链接 Java:

    sudo R CMD javareconf
  2. 回到 R(或 RStudio)从源代码安装 rJava 包:

    install.packages("rJava",type='source')

希望,这会有所帮助!

关于java - 无法在 Mac OS 10.11 上加载 R xlsx 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35179151/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com