简体   繁体   中英

I cannot run R xlsx package on my Mac OS 10.11.5 - El Capitan

I'm trying to run the xlsx package on R but returns this error:

> 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’

I found this link here on Stackoverflow Cannot load R xlsx package on Mac OS 10.11 but it isn't working for me.

The solution was to run sudo R CMD javareconf on Mac Terminal and after install.packages("rJava",type='source') on R. But when I run sudo R CMD javareconf my Mac gives this error: sudo: R: command not found .

Does anyone know how can I fix this issue?


OS Version:

$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.11.5
BuildVersion:   15F34

Java Version:

$ java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

R Version:

> version
           _                           
platform       x86_64-apple-darwin13.4.0   
arch           x86_64                      
os             darwin13.4.0                
system         x86_64, darwin13.4.0        
status                                     
major          3                           
minor          2.3                         
year           2015                        
month          12                          
day            10                          
svn rev        69752                       
language       R                           
version.string R version 3.2.3 (2015-12-10)
nickname       Wooden Christmas-Tree

The error message from your Terminal session actually suggest that your bash PATH does not have the directory for the R executable (or a symlink to it.) But I'm also wondering if augmenting your PATH value will be successful.

The El Capitan version of OSX changed the security policies and move the location for user installed software. I got success after failing with javareconf by issuing this command at a Terminal prompt and then giving my password:

sudo ln -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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