简体   繁体   English

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

[英]Cannot load R xlsx package on Mac OS 10.11

I can load the rJava and xlsxjars packages, but I get a "Failed to load JVM" when I execute library(xlsx).我可以加载 rJava 和 xlsxjars 包,但是在执行 library(xlsx) 时出现“无法加载 JVM”。 Below are my details.以下是我的详细信息。

OS Version:操作系统版本:

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

Java Version:爪哇版:

$ 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 Path: Java路径:

$ which java
/usr/bin/java

Java Home: Java主页:

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

R Version:版本:

$ 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)

How I launch R:我如何启动 R:

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

Loading the rJava and xlsxjars packages successfully:成功加载 rJava 和 xlsxjars 包:

> library(rJava)
> library(xlsxjars)

Unsuccessfully trying to load the xlsx package:尝试加载 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 Configuration: 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

Unfortunately, these symlink tricks didn't help me.不幸的是,这些符号链接技巧对我没有帮助。 However, I found a similar issue on stackoverflow !但是,我在stackoverflow上发现了类似的问题! (where else ;)) This one worked for me by doing the following: (其他地方;))通过执行以下操作,这个对我有用:

  1. In terminal enter the following to relink Java correctly:在终端中输入以下内容以正确重新链接 Java:

     sudo R CMD javareconf
  2. Back in R (or RStudio) install the rJava package from source:回到 R(或 RStudio),从源代码安装 rJava 包:

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

Hope, this helps!希望这可以帮助!

I ´ve got also problems with loading packages like openNLP, xlsx, RWeka, ... and got the same error message like you.我在加载 openNLP、xlsx、RWeka 等软件包时也遇到了问题,并得到了与您相同的错误消息。 But finally this command worked for me on OS X 10.11.3: sudo ln -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib但最后这个命令在 OS X 10.11.3 上对我有用: sudo ln -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib

There might be a problem in the version of Java for which the R xlsx package was built in. Some old software require to install the Java 6 for OS X 10.11 El Capitan, OS X 10.10 Yosemite, OS X 10.9 Mavericks, OS X 10.8 Mountain Lion, and OS X 10.7 Lion.内置 R xlsx 包的 Java 版本可能存在问题。一些旧软件需要为 OS X 10.11 El Capitan、OS X 10.10 Yosemite、OS X 10.9 Mavericks、OS X 10.8 Mountain 安装 Java 6 Lion 和 OS X 10.7 Lion。 So you can try to install this old version of Java (Java for OS X 2015-001) at Apple website, link below: https://support.apple.com/kb/DL1572?locale=pt_BR&viewlocale=en_US所以你可以尝试在 Apple 网站上安装这个旧版本的 Java(Java for OS X 2015-001),链接如下: https : //support.apple.com/kb/DL1572? locale=pt_BR&viewlocale=en_US

And check if you have a Java SE Development Kit 8. You can download it at Oracle website, link below: www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html并检查您是否有 Java SE Development Kit 8。您可以在 Oracle 网站下载,链接如下: www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

I was having the same problem and downloading the old version of Java solved it.. I hope this help you!我遇到了同样的问题,下载旧版本的 Java 解决了它.. 希望这对你有帮助!

Basically, just do what is described here: https://oliverdowling.com.au/2015/10/09/oracles-jre-8-on-mac-os-x-el-capitan/基本上,只需执行此处描述的操作: https : //oliverdowling.com.au/2015/10/09/oracles-jre-8-on-mac-os-x-el-capitan/

short version: d/l Java JRE from oracle as tar file http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html短版:来自 oracle 的 d/l Java JRE 作为 tar 文件http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html

then put this into you terminal (for sudo, your pw is needed):然后将其放入您的终端(对于 sudo,需要您的密码):

cd ~/Downloads
tar -xzf `ls -1r jre-*-macosx-x64.tar.gz | head -1`
cd `ls -1rd jre*/ | head -1`
defaults write `pwd`/Contents/Info.plist JavaVM -dict-add 'JVMCapabilities' '<array><string>JNI</string><string>BundledApp</string><string>CommandLine</string></array>'
plutil -convert xml1 Contents/Info.plist
sudo mv `pwd` /Library/Java/JavaVirtualMachines/
mkdir -p Contents/Home/bundle/Libraries
cd Contents/Home/bundle/Libraries
ln -s ../../lib/server/libjvm.dylib libserver.dylib

works fine on my OS X 10.11在我的 OS X 10.11 上运行良好

For me, MacOS Catalina 10.15.7, it was as simple as installing the current JRE and JDK software (downloaded as .dmg files from the official distributer websites on java.com and oracle.com - No affiliations whatsoever!).对我来说,MacOS Catalina 10.15.7,就像安装当前的 JRE 和 JDK 软件一样简单(从 java.com 和 oracle.com 上的官方发行商网站下载为 .dmg 文件 - 没有任何隶属关系!)。

I have also (re-) installed the rJava package, but I don't feel this was necessary.我也(重新)安装了 rJava 包,但我觉得没有必要。 I actually simply did not have Java installed on my computer.我实际上只是没有在我的计算机上安装 Java。

Now the xlsx package loads.现在xlsx包加载。

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

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